|
4 | 4 | <qhelp> |
5 | 5 |
|
6 | 6 | <overview> |
7 | | - <p> |
| 7 | + <p> |
8 | 8 | Most JavaScript objects inherit the properties of the built-in <code>Object.prototype</code> object. |
9 | 9 | If an attacker is be able to modify <code>Object.prototype</code>, they can tamper with the |
10 | 10 | application logic and often escalate to remote code execution or cross-site scripting. |
11 | | - </p> |
| 11 | + </p> |
12 | 12 |
|
13 | | - <p> |
| 13 | + <p> |
14 | 14 | One way to cause prototype pollution is through use of an unsafe <em>merge</em> or <em>extend</em> function |
15 | 15 | to recursively copy properties from an untrusted source object. |
16 | 16 | Such a call can modify any object reachable from the destination object, and |
17 | 17 | the built-in <code>Object.prototype</code> is usually reachable through the special properties |
18 | 18 | <code>__proto__</code> and <code>constructor.prototype</code>. |
19 | 19 | An attacker can abuse this by sending an object with these property names and thereby modify <code>Object.prototype</code>. |
20 | | - </p> |
| 20 | + </p> |
21 | 21 | </overview> |
22 | 22 |
|
23 | 23 | <recommendation> |
24 | | - <p> |
| 24 | + <p> |
25 | 25 | Update your library dependencies in order to use a safe version of the <em>merge</em> or <em>extend</em> function. |
26 | 26 | If you library has no fixed version, switch to another library. |
27 | | - </p> |
| 27 | + </p> |
28 | 28 | </recommendation> |
29 | 29 |
|
30 | 30 | <example> |
31 | | - <p> |
| 31 | + <p> |
32 | 32 | In the example below, the untrusted value <code>req.query.prefs</code> is parsed as JSON |
33 | 33 | and then copied into a new object: |
34 | | - </p> |
| 34 | + </p> |
35 | 35 |
|
36 | 36 | <sample src="examples/PrototypePollution1.js"/> |
37 | 37 |
|
38 | | - <p> |
| 38 | + <p> |
39 | 39 | Prior to lodash 4.17.11 this would be vulnerable to prototype pollution. An attacker could send |
40 | 40 | the value <code>{"constructor": {"prototype": {"xxx": true}}}</code> to inject <code>xxx</code> |
41 | 41 | in <code>Object.prototype</code>. |
|
55 | 55 | </example> |
56 | 56 |
|
57 | 57 | <references> |
58 | | - <li>Prototype pollution attacks: |
59 | | - <a href="https://hackerone.com/reports/380873">lodash</a>, |
| 58 | + <li>Prototype pollution attacks: |
| 59 | + <a href="https://hackerone.com/reports/380873">lodash</a>, |
60 | 60 | <a href="https://hackerone.com/reports/454365">jQuery</a>, |
61 | 61 | <a href="https://hackerone.com/reports/381185">extend</a>, |
62 | 62 | <a href="https://hackerone.com/reports/430291">just-extend</a>, |
63 | 63 | <a href="https://hackerone.com/reports/381194">merge.recursive</a>, |
64 | | - </li> |
65 | | - <li>Express: |
66 | | - <a href="https://expressjs.com/en/api.html#express.urlencoded">urlencoded()</a> |
67 | | - </li> |
| 64 | + </li> |
| 65 | + <li>Express: |
| 66 | + <a href="https://expressjs.com/en/api.html#express.urlencoded">urlencoded()</a> |
| 67 | + </li> |
68 | 68 | </references> |
69 | 69 | </qhelp> |
0 commit comments