Home / patterns

Mass assignment: users can set fields like role or is_admin

Quick answer: AI-generated update endpoints often pass the whole request body straight into the database (for example update(req.body) or a Supabase .update(body)). An attacker adds fields you never showed in the form, such as role, is_admin, plan or owner_id, and the app saves them.

Last updated October 19, 2026

Steps

  1. Find every create and update route, server action or edge function, and look for code that spreads or passes the entire request body into an ORM or database call.
  2. On your own app, send an update request with an extra field (for example "role":"admin" or "plan":"pro") and check whether it was saved.
  3. Replace whole-body binding with an explicit allow-list of the fields the caller may edit, or a dedicated input schema (zod, a DTO) that strips everything else.
  4. Keep sensitive columns (role, plan, credits, owner or tenant IDs, verified flags) server-controlled only. Set them from the authenticated session or a trusted backend job, never from client input.
  5. In Supabase or Postgres, back this up with RLS policies and column privileges so a client key can't update protected columns even if app code slips.
  6. Apply the same rule to responses: return only the fields the client needs, not the whole row.

Why it matters

OWASP's Mass Assignment Cheat Sheet explains that frameworks which auto-bind request parameters into objects let attackers create or overwrite fields the developer never intended, and recommends dedicated input objects and explicit allow-lists rather than relying on a block-list. OWASP's API Security Top 10 (2023) folds mass assignment into API3: Broken Object Property Level Authorization.

Sources

OWASP Mass Assignment Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html

OWASP API Security Top 10 2023, API3: Broken Object Property Level Authorization — https://owasp.org/API-Security/editions/2023/en/0xa3-broken-object-property-level-authorization/

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

Free. Unsubscribe anytime. We'll never sell your email.