A form is a suggestion to the user. The server's object binder decides which fields are real. If it copies every key, the attacker can add keys the UI never displayed.
Frameworks often bind request bodies directly to models. Hidden fields such as role, tenant, balance or verified are accepted because the model has them, even though the form does not.
We trust the form because it is ours. Attackers send what the form does not.
What is actually at stake?
Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.
Assets
- Role, tenant and permission fields
- Account status and billing attributes
- Ownership and approval flags
- Internal notes and visibility settings
Actors
- Normal user who inspects the profile API
- Attacker with a valid account and an HTTP client
- Malicious integration sending extra JSON keys
Trust boundaries
- Client JSON to allowed request fields
- Request DTO to persistence model
- Nested object to privileged relationship
- GraphQL input to resolver arguments
Abuse cases
- Add role=admin to a profile update
- Set tenantId or ownerId to another organization
- Use a nested object to reach a protected relation
- Supply a field that the UI hides but the binder accepts
Follow the decision, not the payload
Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.
- 01
Receive
Parse the body into a generic map or an over-permissive model.
- 02
Bind
Copy every supplied key onto the domain object, often recursively.
- 03
Guard
Apply validation to the fields the developer remembered, not to the full input shape.
- 04
Persist
Save the object, including fields the client should never control.
- 05
Escalate
The next authorization decision reads the poisoned field and grants more access.
The GitHub public-key commit of 2012
GitHub, 2012, public disclosure by Egor HomakovA researcher demonstrated that a mass-assignment flaw in GitHub's Rails application let a user add an SSH key to an organization they did not control, then commit to a protected repository.
The profile update endpoint accepted more attributes than the form exposed. Adding a field for a public key was enough to associate it with another organization.
The demonstration briefly placed a commit in a protected repository and forced an emergency fix. It became a defining public example of mass assignment in a high-value platform.
The controller passed the full parameter hash to the model instead of an explicit allowlist, so a client-controlled key reached a privileged association.
Use explicit request schemas or DTOs, bind only named fields, and keep role, tenant and ownership fields out of user-writable models.
Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.
A repeatable testing sequence
- Inspect the update request and the object returned by the API.
- Add guessed fields: role, isAdmin, tenant, balance, verified.
- Try JSON, nested objects and case variants.
- Check whether the new field changes authorization or data.
Where smart people get fooled
- A hidden input is still client-controlled.
- A DTO without an allowlist is not a boundary.
- Client-side validation does not constrain the JSON body.
What would the logs show?
A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.
- Profile updates containing keys that never appear in the legitimate schema
- Role, tenant, owner or verification fields changed by a non-admin
- A single account updating fields across multiple tenants
- Validation errors that name internal model attributes
- Privilege changes shortly after a profile or settings update
index=web sourcetype=app_logs action=profile.update | eval sensitive=if(match(changed_fields,"(role|tenant|owner|verified|balance|plan)"),1,0) | where sensitive=1 AND actor_role!="admin" | stats count values(changed_fields) by user_id, pathFix the decision, then prove it stays fixed
- Bind only an explicit allowlist of fields.
- Validate with a strict schema and reject unknown keys.
- Never expose privileged fields on a user-writable model.
const body = await request.json();
await db.user.update({ where: { id: user.id }, data: body });const input = profileSchema.strict().parse(await request.json());
await db.user.update({
where: { id: user.id },
data: { displayName: input.displayName, timezone: input.timezone }
});An allowlist has two layers: reject unknown keys at the schema boundary, then map only named fields to the persistence call. Never pass a request object directly to an ORM.
Regression tests a reviewer would ask for
Privileged field
GivenA normal user updates their profile
WhenThe body includes role=admin
ThenThe request is rejected and the role is unchanged
Tenant field
GivenA user belongs to tenant A
WhenThe body includes tenantId=B or ownerId=B
ThenThe server ignores or rejects the field and keeps tenant A
Nested relation
GivenThe profile schema has a nested settings object
WhenThe nested object includes an unlisted privileged key
ThenStrict validation rejects the entire request
GraphQL input
GivenA mutation accepts an input type
WhenThe caller supplies a field not declared in the schema
ThenThe GraphQL validator rejects it and no resolver sees it
What this finding is not
Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.
- The field is absent from the HTML form: the API may still accept it.
- The response omits role after the update: inspect the database effect or the next authorization decision.
- The server rejects an unknown top-level field: test nested objects and alternate content types.
- The field is read-only in the UI: read-only is a client convention, not a server guarantee.
Terms you should be able to use precisely
- Mass assignment
- Binding client-supplied keys to object properties without an explicit allowlist.
- DTO
- Data transfer object: a narrow shape that defines exactly what a request may contain.
- Allowlist
- A list of permitted fields or actions; everything else is refused.
- Binder
- Framework code that maps request data onto application objects.
- Over-posting
- Sending extra fields to reach properties the UI did not expose.
- Strict schema
- A validator that rejects unknown keys instead of silently stripping them.
Answer these without reciting a payload
Why is stripping unknown keys not always enough?
Deep or nested objects may still be merged, and a stripped top-level key can hide a nested privileged property. Use a strict schema and an explicit persistence mapping.
Which fields should never be directly writable by a normal user?
Role, tenant, owner, verification status, balance, plan and approval flags. These should be changed only through dedicated, authorized workflows.
How does mass assignment become privilege escalation?
A client writes a field that a later authorization decision trusts, such as role or tenant. The write itself may look like a harmless profile update.
Can you separate the mechanism from the payload?
Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.
Mass Assignment ليست مشكلة إضافة حقل غريب فقط؛ هي أن الخادم يثق بشكل الطلب بدل أن يثق بقائمة حقول محددة.
أخطر الحقول هي الدور، المستأجر، المالك، وحالة التحقق. استخدم Schema صارمًا يرفض المفاتيح غير المعروفة، ثم انسخ الحقول المسموحة واحدًا واحدًا إلى قاعدة البيانات. لا تمرر جسم الطلب مباشرة إلى ORM، ولا تعتمد على إخفاء الحقل من الواجهة.
Which fields can the client set that the UI never shows?