Mass assignment in AI-built apps: the extra JSON field that makes a user an admin (and a 3-minute test)
Mass assignment is when your API takes the whole request body and writes it to the database. The user sends {"name": "Sam"} and nothing goes wrong. An attacker sends {"name": "Sam", "role": "admin", "plan": "pro"} and your app saves all of it. AI-generated CRUD code does this a lot, because update(

Mass assignment is when your API takes the whole request body and writes it to the database. The user sends {"name": "Sam"} and nothing goes wrong. An attacker sends {"name": "Sam", "role": "admin", "plan": "pro"} and your app saves all of it. AI-generated CRUD code does this a lot, because update(req.body) is the shortest way to write an endpoint.
app. patch ( "/api/profile", async ( req, res ) => { await db. user. update ( { where: { id: req. user. id }, data: req. body } ); res. json ( { ok: true } ); } ); Enter fullscreen mode Exit fullscreen mode Safer:
const { name, avatarUrl } = req. body; await db. user. update ( { where: { id: req. user. id }, data: { name, avatarUrl } } ); Enter fullscreen mode Exit fullscreen mode Search your code for data: req.body,...req.body, Object.assign(user, req.body),.update(body) and.insert(body).
Use your own test account and your own app only.
If the browser talks to your tables directly, the same problem shows up as a row policy that lets users update every column. A policy like "users can update their own row" also lets them update role on that row. Fix it with a column allow list, a trigger that blocks changes to sensitive columns, or by moving role and plan into a table users cannot write to.
A scan that never signs in cannot see your write endpoints, so it cannot confirm or rule out mass assignment. Do this check by hand, on a logged-in test account, as part of your pre-launch pass.
Check your own app from the outside, free. Run the free ProofForge scan on your live URL. No account needed for the first scan. It looks at your public site the way a stranger would and says pass, fail or inconclusive, so you know what is confirmed and what it could not see. One-time reports start at $9: see pricing. Building with an AI agent? There is an MCP server so it can check before it deploys.