Skip to main content
HighAI codeOWASP A08:2021CWE-915

How to fix: Mass Assignment Vulnerability Risk

An object spread or direct assignment from request body to database model was detected. Mass assignment allows attackers to set unexpected fields (like role, admin, or isVerified) that should not be user-modifiable.

Why it matters

An attacker can POST { 'role': 'admin', 'isVerified': true, 'balance': 99999 } to an endpoint that uses object spread, instantly elevating their account privileges or modifying protected fields.

AI-generated CRUD APIs commonly write `await db.update({ ...body, id: params.id })`, spreading the entire request body into the database operation. This gives the user control over every field in the table.

How to fix it

  1. 1Explicitly pick only the allowed fields from the request body.
  2. 2Use a schema that defines exactly which fields are user-modifiable.
  3. 3Never spread the entire request body into a database operation.
  4. 4Separate user-modifiable fields from system fields (role, created_at, isVerified) in your schema.

Code examples

Explicit field selection

TypeScript
// Bad (AI-generated mass assignment)
await db.updateUser(userId, { ...body });

// Good: only allow specific fields
const { name, bio, website } = body;
await db.updateUser(userId, {
  name: name?.slice(0, 100),
  bio: bio?.slice(0, 500),
  website: validateUrl(website),
});

References

Detected automatically by VulnRadar. The check id is vibe-mass-assignment, stable across every scan so you can filter or diff on it.

See every ai code check

Questions

How severe is Mass Assignment Vulnerability Risk?
VulnRadar rates this high severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id vibe-mass-assignment, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Mass Assignment Vulnerability Risk map to?
It maps to CWE-915. In the OWASP Top 10 it falls under A08:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for mass assignment vulnerability risk

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Mass Assignment Vulnerability Risk | VulnRadar