Mass Assignment
Mass assignment (autobinding, object injection, over-posting) happens when a framework binds client-supplied keys straight onto an internal object, so a caller can set properties such as
role,isAdmin,credit,priceor internal IDs that the UI never sends. It is the write side of OWASP API3:2023 BOPLA.
How it works
- The naming depends on the framework: mass assignment in Rails and Node, autobinding in Spring MVC and ASP.NET MVC, object injection in PHP.
- The root pattern is
user.update(request.json), orsetAttributes($params, false)in Yii/Craft (wherefalsedisables the safe-attribute filter), ordata.pid || nextPid(). The same model is reused for read and write, and there’s no allowlist of writable fields. - It creates hidden parameters. Any field that exists on the model is accepted even though no client ever sends it. That makes the response body, the spec and GraphQL introspection the best sources of candidate keys.
- It’s invisible to tooling: no payload, no error, a single request,
200 OK. WAFs, rate limits and scanners don’t fire.
Techniques / payloads
Find candidate fields
- Read-back diffing. Compare
GETandPOST/PATCHbodies for the same object. In the PortSwigger lab,GET /api/checkoutreturnedchosen_discount, which thePOSTlacked. - Response leakage. Fields such as
role,is_verified,Profiles,creditandstatusin a create or update response hint that the model will bind them. - Specs and introspection. OpenAPI schemas list every property. GraphQL introspection exposed a
rolefield onUserthat a profile mutation then accepted. See GraphQL Introspection. - Client code. Wiz’s Red Agent pulled request schemas out of 130 MB of JS bundles and found an
unmaskContactDataboolean the free-tier UI never sent. See JavaScript Analysis. - Blind guessing. Fuzz common names with Burp Intruder:
role,admin,is_admin,is_staff,permissions,status,price,approved.
Confirm binding. Send a wrong type first. "chosen_discount":{"percentage":"x"} returned a type error, which proves the key is parsed. Then set the real value.
PATCH /api/users/
{"username":"wiener","email":"wiener@example.com","isAdmin":true}
POST /api/checkout
{"chosen_discount":{"percentage":100},"chosen_products":[{"product_id":"1","quantity":1}]}
POST /vapi/api6/user # credit field never documented
{"name":"x","username":"x","password":"123456","credit":"1000"}
PUT /api/user/update
{"name":"Normal User","phone":"9XXXXXXXXX","role":"admin"}
{"is_admin":true,"is_staff":true,"permissions":["*"]}Where it lives: profile update, registration, admin edit-user, bulk-update endpoints, GraphQL mutations and mobile backends. In practice that’s anywhere that accepts JSON via PUT/PATCH/POST.
What it can change:
- Privilege:
role,Profiles:[{id:1}],isAdmin. - Money:
discount_percentage:100,price:0.01,commission_rate,credit. - Workflow state: crAPI
PUT /orders/{id}with"status":"returned"refunded a delivered order. Other examples areapproved,content_status:"approved"andblocked:false. - Ownership and identity: internal IDs.
- Feature gates:
unmaskContactData:true.
Notable cases
- GitHub (2012). Mass assignment let users attach their SSH public key to any organisation.
- NodeBB
POST /api/v3/topics.req.bodyflowed intoPosts.create, which useddata.pid || incrObjectField('nextPid'). Sending"pid":1re-created the admin’s welcome post under the attacker’s ownership, who could then edit it in place. Fixed in commit 7f08fb9 by deletingpidfrom the body. - Formie (Craft CMS, GHSA-wm3q-jh2w-mm72).
EmailControllerran$notification->setAttributes($notificationParams, false). Every notification field (subject,to,content…) was attacker-controlled and rendered through Twig, so a front-end user got Server-Side Template Injection. Combined with missing authorization. - B2B contact-data platform (Wiz Red Agent). Adding
"unmaskContactData": trueto a free-tier search returned unmasked emails and phone numbers across 600M+ contacts and 135M+ verified phones. The server never checked credit balance or tier. It was fixed in under 2 hours. - Vaadata grey-box test. A user-create response exposed
"Profiles":[{"id":5,...}](customer). Replaying the create withProfilesid1produced an administrator. - vAPI api6. Registering with
"credit":"1000"stuck, andGET /user/meconfirmed it.
Defenses
- Allowlist writable fields per operation, for example
{k:v for k,v in body.items() if k in ["name","phone"]}. Use separate request DTOs (ProfileUpdateRequest) decoupled from persistence entities. Don’t reuse read models for writes. - Reject undeclared properties rather than silently ignoring them. Validate inbound bodies against JSON Schema and enforce
readOnly/writeOnly. - Configure the framework’s binding controls. Rails strong parameters, Laravel’s mass-assignment protection and Spring’s
@ModelAttributebinding are all permissive until configured. Keep Yii/Craft safe-attribute filtering on: never callsetAttributes(..., false)on request input. - Authorize per field. Changing
price,roleorstatusshould need a separate permission check, not just object ownership. Entitlement and pricing flags must be decided server-side. - Strip internal IDs (
pid,user_id,created_at) from bodies before binding.
Related
- API Security
- OWASP API Security Top 10
- Excessive Data Exposure
- API Discovery
- BOLA in APIs
- Function Level Authorization
- Broken Access Control
- GraphQL Authorization Flaws
- Server-Side Parameter Pollution
See also: Business Logic Vulnerabilities
Sources
- API Security 101: Mass Assignment and Exploitation in the Wild · original
- What is Mass Assignment? Attacks and Security Tips · original
- PortSwigger Lab: Exploiting a Mass Assignment Vulnerability · original
- API Testing - Web Security Academy · original
- This Is How I Hacked an API Using Mass Assignment Vulnerability · original
- What Is Broken Object Property Level Authorization? · original
- Finding eight high-severity vulnerabilities in NodeBB in six hours · original
- Formie missing authorization leads to SSTI · original
- The Red Agent POV: The One Boolean That Broke a B2B Platform’s Credit System · original
- Exploiting All 10 OWASP API Security Risks in vAPI (+ Bonus Arena Challenges) · original
- API Security Testing: A Complete Guide to Reconnaissance, Hidden Endpoints, Mass Assignment, and… · original
- OWASP API Security Top 10 Risks · original