A 3-field form made a user admin? Here is how to stop mass assignment
Mass assignment is when your code copies every request field onto the user record, so an attacker adds a field the form never had, like isAdmin. The fix is an allowlist of fields, or a DTO that carries only what you want.

The "edit account" form has three fields: name, email and password. An attacker sends the same request with a fourth field you never drew, and then opens the admin panel. Nothing was broken: your code copied the extra field onto their account. This article shows how this flaw happens, and how to close it with one line in your code.
What is mass assignment?
Mass assignment is a flaw that happens when your code takes every field of a request and copies it onto an object or a database record, without saying which fields are allowed. The attacker uses it to add fields the developer never meant to accept.
The OWASP Mass Assignment Cheat Sheet describes it as an attacker who "can sometimes use this methodology to create new parameters that the developer never intended". The same flaw has more than one name depending on the framework: mass assignment in Ruby on Rails and NodeJS, autobinding in Spring MVC and ASP NET MVC, and object injection in PHP.
For a business owner: picture a clerk who types job applications into the system and copies every line on the paper as it is. If someone writes "salary: double" at the bottom of the paper, the clerk copies that too.
Why doesn't the form protect you?
The form does not protect you because the browser does not decide what reaches the server. The form draws three fields, but anyone can send the request by hand and add whatever they want.
The mistake is human and simple: the developer looks at the form and assumes that is the shape of the request. Here is what the vulnerable code looks like:
app.post('/account', async (req, res) => {
await User.findByIdAndUpdate(req.user.id, req.body);
res.sendStatus(204);
});The line is short and convenient, and that is the problem: all of req.body goes onto the user record, and any record field whose name is in the request gets changed.
How does one field make the attacker an admin?
The attacker becomes an admin because the user record has a permissions field, and the code copies any field whose name matches. The example in the OWASP cheat sheet itself: a form for editing a user's account with userid, password and email, and the object behind it also has isAdmin.
The attacker appends &isAdmin=true to the request, and the framework finds a field with the same name and fills it. No password guessing and no broken crypto: the code did exactly what it was written to do, on a field nobody thought about.
How do you close mass assignment?
You close mass assignment when the code names the allowed fields one by one, and everything else is dropped. OWASP gives two ways.
An allowlist: "Explicitly allow-list fields when binding to an object with additional properties".
A Data Transfer Object (DTO): an object with only the fields the form should change, instead of binding the request directly to the database object.
For Node.js with Mongoose, the cheat sheet gives an example with _.pick on a list of safe fields. The same idea without a library:
const ACCOUNT_FIELDS = ['name', 'email'];
function pickFields(body, allowed) {
return Object.fromEntries(
allowed.filter((key) => key in body).map((key) => [key, body[key]])
);
}
app.post('/account', async (req, res) => {
const update = pickFields(req.body, ACCOUNT_FIELDS);
await User.findByIdAndUpdate(req.user.id, update);
res.sendStatus(204);
});Now isAdmin in the request does nothing, because it is not on the list. And keep password changes on their own route that asks for the old password, not as a field in the same form.
Why isn't a block-list enough?
A block-list is not enough because it only protects you from the fields you remembered. The cheat sheet says it plainly: "Do not rely on a block-list as the sole protection: a new or overlooked sensitive field remains bindable."
So today you block isAdmin, and a month later someone adds plan or credits to the record and the list is not updated. With an allowlist, a new field stays closed until someone opens it on purpose.
Where do you start now?
The lesson for you as a developer: every route that writes to the database should name its fields, because whoever sends the request decides its shape, not the form.
Search your code for every place that passes the whole
req.bodyto a save, update or create call.For each one, write the list of fields that screen should change, and apply it before saving.
Move sensitive fields (permissions, plan, balance) to separate routes with their own permission check.
Test it yourself: send an account update request with an extra field, and see if it was saved.
This flaw sits close to another one on the same routes, when a user edits a record that is not theirs: we wrote about it in checking access for every record. All our app security articles are in one place: app security articles. And if you want someone to try these fields on your platform like an attacker would, that is what Muhassan does.
How many routes in your code save req.body as it is?
FAQ
Are mass assignment and autobinding the same thing?
Yes. The OWASP cheat sheet says the same flaw has different names by framework: mass assignment in Ruby on Rails and NodeJS, autobinding in Spring MVC and ASP NET MVC, and object injection in PHP.
Is a block-list with isAdmin enough?
No. OWASP says not to rely on a block-list alone, because a new or overlooked sensitive field stays bindable. An allowlist flips the rule: a new field stays closed until you open it.
If the form has no isAdmin field, how does the attacker know the name?
They guess, or they read it in an API response if your app returns the full user record as JSON. Do not build the protection on the name being secret.


