Skip to content

Commit 682f279

Browse files
committed
JS: Address comments
1 parent 7782448 commit 682f279

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

javascript/ql/src/Security/CWE-400/PrototypePollution.qhelp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<overview>
77
<p>
88
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.
1112
</p>
1213

1314
<p>
@@ -36,9 +37,13 @@
3637
<sample src="examples/PrototypePollution1.js"/>
3738

3839
<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>.
4247
Fix this by updating the lodash version:
4348
</p>
4449

@@ -47,11 +52,17 @@
4752
<p>
4853
Note that some web frameworks, such as Express, parse query parameters using extended URL-encoding
4954
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>.
5156
The example below would also be susceptible to prototype pollution:
5257
</p>
5358

5459
<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>
5566
</example>
5667

5768
<references>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
app.get('/news', (req, res) => {
2-
let prefs = lodash.merge({}, {
3-
topic: req.query.topic
2+
let config = lodash.merge({}, {
3+
prefs: req.query.prefs
44
});
55
})

0 commit comments

Comments
 (0)