Group
  • Security

    Prevent mass assignment on my update endpoints

    Stops endpoints from writing whatever fields the client sends, so users can't grant themselves admin or change prices.

    • Improve quality
    • Debug & fix
    • Intermediate
    • Cursor
    • General

Free Prompt

Audit my app for mass assignment vulnerabilities. Look at every endpoint that creates or updates a record, especially ones that spread or assign the request body directly into a database write (patterns like update(id, req.body) or Object.assign(record, payload)). For each one, replace bulk assignment with an explicit allowlist of fields the client is permitted to change. Fields like role, is_admin, plan, balance, price, user_id, and created_at must never be writable from the request body. If different user types can change different fields (a user edits their profile, an admin edits roles), split the allowlists per role rather than widening one. Do not change which fields users can legitimately edit in the UI. Do not rename request or response fields. Keep the API contract identical for legitimate clients. Give me a table of every create/update endpoint, the fields it accepted before, and the allowlist it enforces now. Include a test I can run: submit a profile update that also includes { "role": "admin" } and confirm the extra field is ignored or rejected.

What This Does / How This Helps

Finds the endpoints that write whatever fields the client sends and replaces that with explicit allowlists of editable fields. Mass assignment is the bug where a profile update endpoint happily accepts { "role": "admin" } or { "balance": 1000000 } alongside the name change, because the code dumps the whole request body into the database. The UI never sends those fields, but nothing stops anyone from adding them to the request. The per-endpoint table plus the role-injection test makes the fix provable: send the sneaky payload, confirm it does nothing.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts