Testing API for Mass Assignment Vulnerability
When to Use
- Testing API endpoints that accept JSON/XML request bodies for user profile updates, registration, or object creation
- Assessing whether the API binds all client-supplied properties to the data model without an allowlist
- Evaluating if users can set privileged attributes (role, permissions, pricing, balance) through regular update endpoints
- Testing APIs built with ORMs that auto-bind request parameters to database models
- Validating that server-side input validation restricts writeable properties per user role
Do not use without written authorization. Mass assignment testing involves modifying object properties in potentially destructive ways.
Prerequisites
- Written authorization specifying target API endpoints and scope
- Test accounts at different privilege levels
- API documentation or OpenAPI specification to identify expected request fields
- Burp Suite Professional for request interception and parameter injection
- Python 3.10+ with
requests library
- Knowledge of the backend framework (Rails, Django, Express, Spring) to predict parameter binding behavior
Workflow
Step 1: Identify Writable Endpoints and Expected Parameters
import requests
import json
import copy
BASE_URL = "https://target-api.example.com/api/v1"
user_headers = {"Authorization": "Bearer <user_token>", "Content-Type": "application/json"}
# Identify endpoints that accept write operations
writable_endpoints = [
{"method": "POST", "path": "/users/register", "expected_fields": ["email", "password", "name"]},
{"method": "PUT", "path": "/users/me", "expected_fields": ["name", "email", "avatar"]},
{"method": "PATCH", "path": "/users/me", "expected_fields": ["name", "bio"]},
{"method": "POST", "path": "/orders", "expected_fields": ["items", "shipping_address"]},
{"method": "PUT", "path": "/orders/1001", "expected_fields": ["shipping_address"]},
{"method": "POST", "path": "/products", "expected_fields": ["name", "description", "price"]},
{"method": "POST", "path": "/comments", "expected_fields": ["body", "post_id"]},
{"method": "PUT", "path": "/settings", "expected_fields": ["notifications", "language"]},
]
# First, get the current user state as baseline
baseline_user = requests.get(f"{BASE_URL}/users/me", headers=user_headers).json()
print(f"Baseline user state: {json.dumps(baseline_user, indent=2)}")
Step 2: Inject Privileged Fields
> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.
1---2name: testing-api-for-mass-assignment-vulnerability3description: "Tests APIs for mass assignment (OWASP API3:2023). Signals: API attacks, interface testing."4zh-signals: "Tests APIs for mass assignment (auto-binding), OWASP API3:2023, by identifying 信号:api攻击,接口测试。"5when-to-use: 'Tests APIs for mass assignment (auto-binding), OWASP API3:2023, by identifying6 writable endpoints, adding undocumented fields to request bodies (role, isAdmin,7 price, balance), and checking whether the server binds them to the data model without8 filtering. Use when testing an API for mass assignment, parameter binding abuse,9 or over-posting on profile, registration, or object-creation endpoints.1011 '12domain: cybersecurity13subdomain: api-security14tags:15- api-security16- owasp17- mass-assignment18- auto-binding19- parameter-tampering20version: 1.0.021author: mahipal22license: Apache-2.023nist_csf:24- PR.PS-0125- ID.RA-0126- PR.DS-1027- DE.CM-0128mitre_attack:29- T119030- T1059.00731- T1552.00132- T081633- T083634metadata:35 source: https://skillmd.com/skills/dangeroussong/testing-api-for-mass-assignment-vulnerability36---3738# Testing API for Mass Assignment Vulnerability3940## When to Use4142- Testing API endpoints that accept JSON/XML request bodies for user profile updates, registration, or object creation43- Assessing whether the API binds all client-supplied properties to the data model without an allowlist44- Evaluating if users can set privileged attributes (role, permissions, pricing, balance) through regular update endpoints45- Testing APIs built with ORMs that auto-bind request parameters to database models46- Validating that server-side input validation restricts writeable properties per user role4748**Do not use** without written authorization. Mass assignment testing involves modifying object properties in potentially destructive ways.4950## Prerequisites5152- Written authorization specifying target API endpoints and scope53- Test accounts at different privilege levels54- API documentation or OpenAPI specification to identify expected request fields55- Burp Suite Professional for request interception and parameter injection56- Python 3.10+ with `requests` library57- Knowledge of the backend framework (Rails, Django, Express, Spring) to predict parameter binding behavior5859## Workflow6061### Step 1: Identify Writable Endpoints and Expected Parameters6263```python64import requests65import json66import copy6768BASE_URL = "https://target-api.example.com/api/v1"69user_headers = {"Authorization": "Bearer <user_token>", "Content-Type": "application/json"}7071# Identify endpoints that accept write operations72writable_endpoints = [73 {"method": "POST", "path": "/users/register", "expected_fields": ["email", "password", "name"]},74 {"method": "PUT", "path": "/users/me", "expected_fields": ["name", "email", "avatar"]},75 {"method": "PATCH", "path": "/users/me", "expected_fields": ["name", "bio"]},76 {"method": "POST", "path": "/orders", "expected_fields": ["items", "shipping_address"]},77 {"method": "PUT", "path": "/orders/1001", "expected_fields": ["shipping_address"]},78 {"method": "POST", "path": "/products", "expected_fields": ["name", "description", "price"]},79 {"method": "POST", "path": "/comments", "expected_fields": ["body", "post_id"]},80 {"method": "PUT", "path": "/settings", "expected_fields": ["notifications", "language"]},81]8283# First, get the current user state as baseline84baseline_user = requests.get(f"{BASE_URL}/users/me", headers=user_headers).json()85print(f"Baseline user state: {json.dumps(baseline_user, indent=2)}")86```8788### Step 2: Inject Privileged Fields8990```python9192> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.