[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79PDJDQFZ5DZ5HV03Q6ZRPV":3,"skill-same:01M79PDJDQFZ5DZ5HV03Q6ZRPV":43},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M79PDJDQFZ5DZ5HV03Q6ZRPV","mass-assignment-cheat-sheet",null,"JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fmass-assignment-cheat-sheet\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# Mass Assignment Cheat Sheet\n\n## Introduction\n\n### Definition\n\nSoftware frameworks sometimes allow developers to automatically bind HTTP request parameters into program code variables or objects to make using that framework easier on developers. This can sometimes cause harm.\n\nAttackers can sometimes use this methodology to create new parameters that the developer never intended which in turn creates or overwrites new variable or objects in program code that was not intended.\n\nThis is called a **Mass Assignment** vulnerability.\n\n### Alternative Names\n\nDepending on the language\u002Fframework in question, this vulnerability can have several [alternative names](https:\u002F\u002Fcwe.mitre.org\u002Fdata\u002Fdefinitions\u002F915.html):\n\n- **Mass Assignment:** Ruby on Rails, NodeJS.\n- **Autobinding:** Spring MVC, ASP NET MVC.\n- **Object injection:** PHP.\n\n### Example\n\nSuppose there is a form for editing a user's account information:\n\n```html\n\u003Cform>\n     \u003Cinput name=\"userid\" type=\"text\">\n     \u003Cinput name=\"password\" type=\"text\">\n     \u003Cinput name=\"email\" text=\"text\">\n     \u003Cinput type=\"submit\">\n\u003C\u002Fform>  \n```\n\nHere is the object that the form is binding to:\n\n```java\npublic class User {\n   private String userid;\n   private String password;\n   private String email;\n   private boolean isAdmin;\n\n   \u002F\u002FGetters & Setters\n}\n```\n\nHere is the controller handling the request:\n\n```java\n@RequestMapping(value = \"\u002FaddUser\", method = RequestMethod.POST)\npublic String submit(User user) {\n   userService.add(user);\n   return \"successPage\";\n}\n```\n\nHere is the typical request:\n\n```text\nPOST \u002FaddUser\n...\nuserid=bobbytables&password=hashedpass&email=bobby@tables.com\n```\n\nAnd here is the exploit in which we set the value of the attribute `isAdmin` of the instance of the class `User`:\n\n```text\nPOST \u002FaddUser\n...\nuserid=bobbytables&password=hashedpass&email=bobby@tables.com&isAdmin=true\n```\n\n### Exploitability\n\nMass assignment is exploitable when attacker-controlled input can initialize or update fields that the caller is not authorized to change, such as a role or account owner. Field names may be guessed or discovered; source-code access is not required. [CWE-915](https:\u002F\u002Fcwe.mitre.org\u002Fdata\u002Fdefinitions\u002F915.html) defines the weakness in terms of insufficient control over writable attributes.\n\nAn empty constructor is not a general prerequisite. For example, [Spring supports both constructor and setter binding](https:\u002F\u002Fdocs.spring.io\u002Fspring-framework\u002Freference\u002Fweb\u002Fwebmvc\u002Fmvc-data-binding.html). Review which inputs the binding mechanism exposes, including nested objects.\n\n### GitHub case study\n\nIn 2012, GitHub was hacked using mass assignment. A user was able to upload his public key to any organization and thus make any subsequent changes in their repositories. [GitHub's Blog Post](https:\u002F\u002Fblog.github.com\u002F2012-03-04-public-key-security-vulnerability-and-mitigation\u002F).\n\n### Solutions\n\n- Prefer dedicated input objects, such as Data Transfer Objects (DTOs), containing only fields the caller may edit; see [Spring's model design guidance](https:\u002F\u002Fdocs.spring.io\u002Fspring-framework\u002Freference\u002Fweb\u002Fwebmvc\u002Fmvc-data-binding.html).\n- Explicitly allow-list fields when binding to an object with additional properties.\n- Do not rely on a block-list as the sole protection: a new or overlooked sensitive field remains bindable. [CWE-915 recommends allowlists over denylists](https:\u002F\u002Fcwe.mitre.org\u002Fdata\u002Fdefinitions\u002F915.html). The block-list examples below illustrate mechanisms encountered in existing applications, not the recommended design.\n\nDTOs and field allowlists restrict writable properties; they do not replace [authorization for the requested object and operation](Authorization_Cheat_Sheet.md#validate-the-permissions-on-every-request).\n\n## General Solutions\n\nAn architectural approach is to create Data Transfer Objects and avoid binding input directly to domain objects. Only the fields that are meant to be editable by the user are included in the DTO.\n\n```java\npublic class UserRegistrationFormDTO {\n private String userid;\n private String password;\n private String email;\n\n \u002F\u002FNOTE: isAdmin field is not present\n\n \u002F\u002FGetters & Setters\n}\n```\n\n## Language & Framework specific solutions\n\n### Spring MVC\n\n#### Allow-listing\n\n```java\n@Controller\npublic class UserController\n{\n    @InitBinder\n    public void initBinder(WebDataBinder binder, WebRequest request)\n    {\n        binder.setAllowedFields(\"userid\", \"password\", \"email\");\n    }\n...\n}\n```\n\nSee [Spring's model design guidance](https:\u002F\u002Fdocs.spring.io\u002Fspring-framework\u002Freference\u002Fweb\u002Fwebmvc\u002Fmvc-data-binding.html) for dedicated input objects and allowed fields.\n\n#### Block-listing\n\nSpring describes `disallowedFields` as fragile because fields can be missed or added later. Prefer the allow-list above; this example only excludes the named property.\n\n```java\n@Controller\npublic class UserController\n{\n   @InitBinder\n   public void initBinder(WebDataBinder binder, WebRequest request)\n   {\n      binder.setDisallowedFields(\"isAdmin\");\n   }\n...\n}\n```\n\nSee the [Spring data binding limitations](https:\u002F\u002Fdocs.spring.io\u002Fspring-framework\u002Freference\u002Fweb\u002Fwebmvc\u002Fmvc-data-binding.html).\n\n### NodeJS + Mongoose\n\n#### Allow-listing\n\n```javascript\nvar UserSchema = new mongoose.Schema({\n    userid: String,\n    password: String,\n    email : String,\n    isAdmin : Boolean,\n});\n\nUserSchema.statics = {\n    User.userCreateSafeFields: ['userid', 'password', 'email']\n};\n\nvar User = mongoose.model('User', UserSchema);\n\n_ = require('underscore');\nvar user = new User(_.pick(req.body, User.userCreateSafeFields));\n```\n\nTake a look [here](http:\u002F\u002Funderscorejs.org\u002F#pick) for the documentation.\n\n#### Block-listing\n\n```javascript\nvar massAssign = require('mongoose-mass-assign');\n\nvar UserSchema = new mongoose.Schema({\n    userid: String,\n    password: String,\n    email : String,\n    isAdmin : { type: Boolean, protect: true, default: false }\n});\n\nUserSchema.plugin(massAssign);\n\nvar User = mongoose.model('User', UserSchema);\n\n\u002F** Static method, useful for creation **\u002F\nvar user = User.massAssign(req.body);\n\n\u002F** Instance method, useful for updating**\u002F\nvar user = new User;\nuser.massAssign(req.body);\n\n\u002F** Static massUpdate method **\u002F\nvar input = { userid: 'bhelx', isAdmin: 'true' };\nUser.update({ '_id': someId }, { $set: User.massUpdate(input) }, console.log);\n```\n\nTake a look [here](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fmongoose-mass-assign) for the documentation.\n\n### Ruby On Rails\n\nTake a look [here](https:\u002F\u002Fguides.rubyonrails.org\u002Fv3.2.9\u002Fsecurity.html#mass-assignment) for the documentation.\n\n### Django\n\nTake a look [here](https:\u002F\u002Fcoffeeonthekeyboard.com\u002Fmass-assignment-security-part-10-855\u002F) for the documentation.\n\n### ASP NET\n\nTake a look [here](https:\u002F\u002Fodetocode.com\u002FBlogs\u002Fscott\u002Farchive\u002F2012\u002F03\u002F11\u002Fcomplete-guide-to-mass-assignment-in-asp-net-mvc.aspx) for the documentation.\n\n### PHP Laravel + Eloquent\n\n#### Allow-listing\n\n```php\n\u003C?php\n\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass User extends Model\n{\n    private $userid;\n    private $password;\n    private $email;\n    private $isAdmin;\n\n    protected $fillable = array('userid','password','email');\n}\n```\n\nTake a look [here](https:\u002F\u002Flaravel.com\u002Fdocs\u002F5.2\u002Feloquent#mass-assignment) for the documentation.\n\n#### Block-listing\n\n```php\n\u003C?php\n\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass User extends Model\n{\n    private $userid;\n    private $password;\n    private $email;\n    private $isAdmin;\n\n    protected $guarded = array('isAdmin');\n}\n```\n\nTake a look [here](https:\u002F\u002Flaravel.com\u002Fdocs\u002F5.2\u002Feloquent#mass-assignment) for the documentation.\n\n### Grails\n\nTake a look [here](http:\u002F\u002Fspring.io\u002Fblog\u002F2012\u002F03\u002F28\u002Fsecure-data-binding-with-grails\u002F) for the documentation.\n\n### Play\n\nTake a look [here](https:\u002F\u002Fwww.playframework.com\u002Fdocumentation\u002F1.4.x\u002Fcontrollers#nobinding) for the documentation.\n\n### Jackson (JSON Object Mapper)\n\nTake a look [here](https:\u002F\u002Fwww.baeldung.com\u002Fjackson-field-serializable-deserializable-or-not) and [here](http:\u002F\u002Flifelongprogrammer.blogspot.com\u002F2015\u002F09\u002Fusing-jackson-view-to-protect-mass-assignment.html) for the documentation.\n\n### GSON (JSON Object Mapper)\n\nTake a look [here](https:\u002F\u002Fsites.google.com\u002Fsite\u002Fgson\u002Fgson-user-guide#TOC-Excluding-Fields-From-Serialization-and-Deserialization) and [here](https:\u002F\u002Fstackoverflow.com\u002Fa\u002F27986860) for the document.\n\n### JSON-Lib (JSON Object Mapper)\n\nTake a look [here](http:\u002F\u002Fjson-lib.sourceforge.net\u002Fadvanced.html) for the documentation.\n\n### Flexjson (JSON Object Mapper)\n\nTake a look [here](http:\u002F\u002Fflexjson.sourceforge.net\u002F#Serialization) for the documentation.\n\n## References\n\n- [Ruby on Rails: Strong Parameters](https:\u002F\u002Fguides.rubyonrails.org\u002Faction_controller_overview.html#strong-parameters)\n- [Spring Framework: DataBinder Security Considerations](https:\u002F\u002Fdocs.spring.io\u002Fspring-framework\u002Fdocs\u002Fcurrent\u002Fjavadoc-api\u002Forg\u002Fspringframework\u002Fvalidation\u002FDataBinder.html)\n",{},"main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Fmass-assignment-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill mass-assignment-cheat-sheet",{"tool":35,"command":36},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill mass-assignment-cheat-sheet",{"tool":38,"command":39},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill mass-assignment-cheat-sheet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fmass-assignment-cheat-sheet\u002FSKILL.md",true,[],[44,50,56,62,68,74],{"skillNo":45,"name":46,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":47,"categories":48,"keywords":49,"publishedAt":18},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]