Urgent.News

What's breaking now, across hundreds of outlets.

AI

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(req.body) is the shortest way to write an endpoint. 1. The pattern to look for Unsafe: app . patch (…

Mass assignment occurs when an API takes an entire request body and writes it directly to the database. An attacker can exploit this by sending additional fields in the request, such as "role":"admin" or "plan":"pro", which the app would then save alongside the user's details. AI-generated CRUD code often uses update(req.body) as the shortest way to write an endpoint, making it susceptible to this vulnerability.

To mitigate the risk, developers should look for patterns like data: req.body, ...req.body, Object.assign(user, req.body), .update(body), and .insert(body) in their code. Fields that should be protected include role, is_admin, permissions, plan, tier, credits, balance, user_id, owner_id, and org_id. A quick 3-minute test involves testing the endpoint by signing in as a normal user and attempting to add extraneous fields to a form.

If the new value persists after reloading the profile, the endpoint is vulnerable to mass assignment. The issue can also be seen in Supabase and Firebase apps, where browser communication with tables directly allows users to update any column. To address this, developers can implement an explicit allow list of fields for every write endpoint, validate the request body with a schema that rejects unknown keys, and keep sensitive fields like role and plan in separate tables that cannot be written to by users.

Always re-check ownership on every update and never trust an owner_id provided by the client. While automated scans can provide some insights, they cannot fully confirm or rule out mass assignment, as they may not see private write endpoints. A manual check by a signed-in test account should be performed as part of pre-launch security testing.

Additionally, free tools like ProofForge can be used to scan the live app from the outside, helping developers identify any potential vulnerabilities.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

Chat Memory per User in Java with LangChain4j and Claude: Using @MemoryId

Most AI examples end the same way when they go to production: a single shared conversation starts mixing people together.

  • Use @MemoryId annotation to isolate conversations in LangChain4j
  • Each conversation gets a unique memory object with MessageWindowChatMemory
  • Limit conversation history to 10 messages to control costs and quality

More from Saturday, 28 November 2026 →