|
6 | 6 | <overview> |
7 | 7 | <p> |
8 | 8 | Most JavaScript objects inherit the properties of the built-in <code>Object.prototype</code> object. |
9 | | - If an attacker is be able to modify <code>Object.prototype</code>, they can tamper with the |
10 | | - application logic and often escalate to remote code execution or cross-site scripting. |
| 9 | + Prototype pollution is a type of vulnerability in which an attacker is be able to modify <code>Object.prototype</code>. |
| 10 | + Since most objects inherit from the compromised <code>Object.prototype</code>, the attacker can use this |
| 11 | + to tamper with the application logic, and often escalate to remote code execution or cross-site scripting. |
11 | 12 | </p> |
12 | 13 |
|
13 | 14 | <p> |
|
36 | 37 | <sample src="examples/PrototypePollution1.js"/> |
37 | 38 |
|
38 | 39 | <p> |
39 | | - Prior to lodash 4.17.11 this would be vulnerable to prototype pollution. An attacker could send |
40 | | - the value <code>{"constructor": {"prototype": {"xxx": true}}}</code> to inject <code>xxx</code> |
41 | | - in <code>Object.prototype</code>. |
| 40 | + Prior to lodash 4.17.11 this would be vulnerable to prototype pollution. An attacker could send the following GET request: |
| 41 | + </p> |
| 42 | + |
| 43 | + <pre>GET /news?prefs={"constructor":{"prototype":{"xxx":true}}}</pre> |
| 44 | + |
| 45 | + <p> |
| 46 | + This causes the <code>xxx</code> property to be injected on <code>Object.prototype</code>. |
42 | 47 | Fix this by updating the lodash version: |
43 | 48 | </p> |
44 | 49 |
|
|
47 | 52 | <p> |
48 | 53 | Note that some web frameworks, such as Express, parse query parameters using extended URL-encoding |
49 | 54 | by default. |
50 | | - In this case, the application may be vulnerable even if not using <code>JSON.parse</code>. |
| 55 | + When this is the case, the application may be vulnerable even if not using <code>JSON.parse</code>. |
51 | 56 | The example below would also be susceptible to prototype pollution: |
52 | 57 | </p> |
53 | 58 |
|
54 | 59 | <sample src="examples/PrototypePollution2.js"/> |
| 60 | + |
| 61 | + <p> |
| 62 | + In the above example, an attacker can cause prototype pollution by sending the following GET request: |
| 63 | + </p> |
| 64 | + |
| 65 | + <pre>GET /news?prefs[constructor][prototype][xxx]=true</pre> |
55 | 66 | </example> |
56 | 67 |
|
57 | 68 | <references> |
|
0 commit comments