API6:2023 - Mass Assignment Vulnerability
Mass Assignment is a critical security vulnerability that occurs when an application automatically binds client-provided data to internal object properties without proper filtering. This vulnerability allows attackers to modify object properties that should not be publicly accessible, potentially leading to privilege escalation and unauthorized access.
Mass Assignment happens when developers create object instances and expose internal parameters that should remain private. For example, when creating a user object, developers might include sensitive fields like account_type, is_admin, or role. If these parameters are not properly protected, attackers can manipulate them through API requests.
Consider a typical user registration or profile update system. Developers create a user object with various properties including publicly editable fields (name, email) and sensitive fields (user_type, permissions, account_status). If the API endpoint doesn't validate which fields can be modified, attackers can inject unauthorized parameters.
First, let's examine a legitimate user profile update request:
This request updates the user's name fields, which is expected behavior.
After sending the legitimate request, examine the API response:
Now, attempt to modify the hidden parameter by including it in your request:
By copying the user_type parameter from the response and changing its value from "user" to "admin", the attacker attempts to elevate their privileges. If the API doesn't validate incoming parameters, this modification will be accepted, granting unauthorized administrative access.
After sending the malicious request, check the response:
Only accept and process explicitly defined parameters that users should be able to modify.
Create specific objects that define exactly what data can be transferred between client and server.
Verify that the current user has permission to modify each specific property.
Implement strict schema validation to reject requests with unexpected fields.
| Impact Category | Severity | Description |
|---|---|---|
| Privilege Escalation | CRITICAL | Attackers can elevate their permissions to admin or superuser levels |
| Data Manipulation | HIGH | Unauthorized modification of sensitive database records |
| Account Takeover | CRITICAL | Ability to modify account ownership or authentication parameters |
| Business Logic Bypass | HIGH | Circumventing payment systems, approval workflows, or verification processes |
| Compliance Violations | MEDIUM | Breach of GDPR, PCI-DSS, or other regulatory requirements |