Course contentsShow
← Security
Lesson 993 of 3,05221. Web Security - API SecurityFree lesson

Mass Assignment Vulnerabilities in REST APIs

Manipulate object properties by injecting unexpected parameters that map to internal model attributes or sensitive fields.

Mass Assignment Vulnerabilities in REST APIs

You'll learn: How attackers manipulate internal object properties by sneaking unexpected parameters into API requests that map to sensitive fields.

What Is Mass Assignment?

Imagine a form where you can update your profile name and email—but an attacker discovers they can also send an isAdmin=true field in the same request. If the API blindly accepts all incoming parameters and maps them directly to your user object, congratulations: they just promoted themselves to administrator.

Mass assignment happens when an API automatically binds request parameters to internal object properties without explicitly controlling which fields are allowed. In REST APIs, this typically occurs during POST, PUT, or PATCH operations where JSON payloads are directly assigned to database models.

How It Works in REST

Consider an API endpoint PATCH /api/users/123 that expects:

{
  "name": "Alice",
  "email": "alice@example.com"
}

But the underlying User model also has sensitive fields like role, credits, or accountStatus. An attacker sends:

{
  "name": "Alice",
  "email": "alice@example.com",
  "role": "admin",
  "credits": 9999
}

If the backend blindly assigns all received fields to the User object, the attacker just modified properties they shouldn't touch. The API gave them a "mass assignment" of values—including unauthorized ones.

Why This Matters

Mass assignment transforms user input into privilege escalation. Attackers probe API documentation, error messages, or source code to discover internal field names. Common targets: isAdmin, verified, accountBalance, permissions, userId, or isActive.

Key Takeaway:
Mass assignment lets attackers modify sensitive internal properties by injecting unexpected parameters—always whitelist allowed fields and never trust client input to update objects directly.