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, price or 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), or setAttributes($params, false) in Yii/Craft (where false disables the safe-attribute filter), or data.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 GET and POST/PATCH bodies for the same object. In the PortSwigger lab, GET /api/checkout returned chosen_discount, which the POST lacked.
  • Response leakage. Fields such as role, is_verified, Profiles, credit and status in a create or update response hint that the model will bind them.
  • Specs and introspection. OpenAPI schemas list every property. GraphQL introspection exposed a role field on User that 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 unmaskContactData boolean 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 are approved, content_status:"approved" and blocked: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.body flowed into Posts.create, which used data.pid || incrObjectField('nextPid'). Sending "pid":1 re-created the admin’s welcome post under the attacker’s ownership, who could then edit it in place. Fixed in commit 7f08fb9 by deleting pid from the body.
  • Formie (Craft CMS, GHSA-wm3q-jh2w-mm72). EmailController ran $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": true to 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 with Profiles id 1 produced an administrator.
  • vAPI api6. Registering with "credit":"1000" stuck, and GET /user/me confirmed 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 @ModelAttribute binding are all permissive until configured. Keep Yii/Craft safe-attribute filtering on: never call setAttributes(..., false) on request input.
  • Authorize per field. Changing price, role or status should 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.

See also: Business Logic Vulnerabilities

Sources