Mass assignment
Many frameworks automatically bind request fields to an object’s (model’s)
properties. If which fields are bindable isn’t filtered, the attacker adds fields
they shouldn’t control (role, isAdmin, balance, verified, user_id) and modifies
privileged data. It’s the write side of broken access control —and, together with
excessive data exposure, forms the API3:2023 BOPLA category of the OWASP API Top 10—.
It’s also called autobinding or overposting.
flowchart LR
A[Attacker] -->|"JSON with extra fields: role=admin"| B["Model binder (binds EVERYTHING)"]
B -->|"user.update(req.body)"| M[(Model / DB)]
M -->|"role, balance, owner overwritten"| P["Privilege escalated"]
Threat model
Section titled “Threat model”Privilege escalation (role=admin, isAdmin=true), state manipulation (balance,
verification, price, object ownership), and account takeover. The attacker exploits no
memory bug: they use the framework’s own binder against the app.
Anatomy
Section titled “Anatomy”The vulnerable pattern is binding the whole input to the persistent model:
user.update(req.body), a model binder mapping all JSON/form fields, or an ORM that
accepts a full dictionary. The flaw appears when that binding is not restricted to an
allow-list: if the persistent object is filled from the request with no field filtering,
any unlisted property becomes writable from outside. Sharing one class for input and
persistence makes this easy to get wrong, but it isn’t sufficient on its own — an
allow-list, non-public setters or binder restrictions can still block assignment; the risk
is the absence of such filtering.
The invariant the attack breaks: only the fields the user may legitimately edit should
be bindable; the rest (role, owner, balance) are set by the server.
Variants
Section titled “Variants”- Flat overposting: add top-level fields (
role,verified). - Nested / relationship binding:
{"user":{"role":"admin"}}oraccount_idto reassign an object’s ownership. - Arrays and collections: inject elements into bound lists (permissions, roles).
- Type juggling: send
isAdmin:true(boolean) or"1"vs1so a weak binder or validation coerces the value and assigns it anyway.
Red Team
Section titled “Red Team”Discovery
Section titled “Discovery”The goal is to learn which fields exist in the model even if the form doesn’t show them:
- Accept-vs-return diffing: if a
GETof the resource returnsrole/verified, try sending them in thePOST/PUT/PATCH. What the API shows, it often accepts. - Specification: OpenAPI/Swagger, documentation, or the source (models, migrations, serializers) if available or leaked.
- Common names:
admin,is_admin,role,roles,status,approved,verified,owner,user_id,account_id,balance,credit,price. - Nested level: also try the same keys inside objects (
{"user":{...}}).
Exploitation
Section titled “Exploitation”Legitimate request vs request with injected fields:
POST /api/account HTTP/1.1Content-Type: application/json
{"name":"joe","email":"a@b.c","password":"x"}POST /api/account HTTP/1.1Content-Type: application/json
{"name":"joe","email":"a@b.c","password":"x", "role":"admin","isAdmin":true,"verified":true,"balance":99999,"owner_id":1}Confirm impact by reading the resource afterwards: if role changed to admin, it’s
confirmed. Reassigning owner_id/account_id often chains with
IDOR/BOLA to take over others’ objects.
Framework specifics
Section titled “Framework specifics”Each stack has its allow-list mechanism; its absence or misuse is the flaw:
| Framework | Correct mechanism | Vulnerable symptom |
|---|---|---|
| Rails | params.permit(:a, :b) (strong params) |
permit! or update(params[:user]) unfiltered; legacy models with no attr_accessible (pre–strong-params) |
| Spring | @InitBinder + setAllowedFields; DTOs |
@ModelAttribute binding the whole entity |
| Django / DRF | ModelForm Meta.fields; serializer fields |
fields = '__all__'; Model.objects.create(**request.data) |
| Laravel | $fillable on the model |
$guarded = [] or Model::unguard() |
| .NET MVC/Web API | [Bind(Include=...)], DTOs |
direct entity binding (overposting) |
By hand (the researcher’s flow)
Section titled “By hand (the researcher’s flow)”- Which fields does the resource return that the form doesn’t ask for? → injection candidates.
- Send them in the create/update request (flat and nested).
- Did a privileged field change? → impact. Did I reassign ownership? → chain with IDOR.
- Prove with a minimal PoC (e.g. your user becomes
admin), without touching real data.
Tooling
Section titled “Tooling”Burp Suite (add fields and compare responses), arjun/param-miner to discover hidden parameters, and the OpenAPI spec if available.
Impact and chaining
Section titled “Impact and chaining”Escalation to admin, change of an object’s owner (with IDOR), fraud (balance/price, see business logic), and ATO. In APIs it’s among the best-paid flaws for its direct impact.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”Requests with unexpected fields for that endpoint; changes of role, state or ownership through routes that shouldn’t allow them; divergence between the declared schema and the received body.
Telemetry and sources
Section titled “Telemetry and sources”App logs with the received body (sanitized) and the written fields, API-gateway schema
validation, and audit of changes to sensitive fields (role, owner, balance).
Hardening
Section titled “Hardening”- Allow-list of bindable fields (DTOs,
permit,$fillable,[Bind]); never bind the whole object. - Sensitive fields (
role,isAdmin,owner,balance) only modifiable by the server or an explicit authorized flow. - Separate the input model (DTO) from the persistence one.
- Schema validation (OpenAPI) that rejects unknown properties
(
additionalProperties: false).
Response
Section titled “Response”Revert unauthorized changes, fix the binder (allow-list), and audit which accounts changed role, state or ownership.
CVEs and real-world cases
Section titled “CVEs and real-world cases”- GitHub / Rails (2012) — Egor Homakov added an unexpected field to a request and
associated his public key with someone else’s repository (
rails/rails), demonstrating commits in others’ names. The canonical case: it changed Rails’ defaults toward strong params. - Modern APIs — still frequent in Node/Express, Laravel and Spring that bind the whole body to the model; it recurs in bug-bounty reports as privilege escalation.
Specific CVEs/incidents in NVD (https://nvd.nist.gov/vuln/search) and GitHub Advisories (https://github.com/advisories).
Testing checklist
Section titled “Testing checklist”- Extra fields (
role,isAdmin,verified,owner) sent on registration and update. - Accepted vs returned fields compared across the API.
- Nested binding (
{"user":{"role":"admin"}}) and ownership reassignment tested. - Common privileged field names tried.
- Privileged-field change confirmed with a minimal PoC (without touching real accounts).