Skip to content

Commit 13b1e97

Browse files
committed
JS: Fix the ExtendCall restriction
1 parent eafef91 commit 13b1e97

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/PrototypePollutingAssignmentQuery.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ class Configuration extends TaintTracking::Configuration {
6262
// step because it preserves all properties, but the destination is not actually Object.prototype.
6363
exists(ExtendCall call |
6464
pred = call.getASourceOperand() and
65-
succ = call.getDestinationOperand().getALocalSource() and
65+
(
66+
succ = call.getDestinationOperand().getALocalSource()
67+
or
68+
succ = call
69+
) and
6670
lbl instanceof ObjectPrototype
6771
)
6872
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| query-tests/Security/CWE-915/PrototypePollutingAssignment/tst.js:120 | did not expect an alert, but found an alert for PrototypePollutingAssignment | OK - 'object' is not Object.prototype itself (but possibly a copy) | PrototypePollutingAssignment |

javascript/ql/test/query-tests/Security/CWE-915/PrototypePollutingAssignment/PrototypePollutingAssignment.expected

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,6 @@ nodes
190190
| tst.js:105:5:105:17 | object[taint] |
191191
| tst.js:105:5:105:17 | object[taint] |
192192
| tst.js:105:12:105:16 | taint |
193-
| tst.js:116:9:116:38 | taint |
194-
| tst.js:116:17:116:38 | String( ... y.data) |
195-
| tst.js:116:24:116:37 | req.query.data |
196-
| tst.js:116:24:116:37 | req.query.data |
197-
| tst.js:119:9:119:51 | object |
198-
| tst.js:119:18:119:51 | Object. ... taint]) |
199-
| tst.js:119:36:119:50 | plainObj[taint] |
200-
| tst.js:119:45:119:49 | taint |
201-
| tst.js:120:5:120:10 | object |
202-
| tst.js:120:5:120:10 | object |
203193
edges
204194
| lib.js:1:38:1:40 | obj | lib.js:6:7:6:9 | obj |
205195
| lib.js:1:38:1:40 | obj | lib.js:6:7:6:9 | obj |
@@ -376,15 +366,6 @@ edges
376366
| tst.js:102:24:102:37 | req.query.data | tst.js:102:17:102:38 | String( ... y.data) |
377367
| tst.js:105:12:105:16 | taint | tst.js:105:5:105:17 | object[taint] |
378368
| tst.js:105:12:105:16 | taint | tst.js:105:5:105:17 | object[taint] |
379-
| tst.js:116:9:116:38 | taint | tst.js:119:45:119:49 | taint |
380-
| tst.js:116:17:116:38 | String( ... y.data) | tst.js:116:9:116:38 | taint |
381-
| tst.js:116:24:116:37 | req.query.data | tst.js:116:17:116:38 | String( ... y.data) |
382-
| tst.js:116:24:116:37 | req.query.data | tst.js:116:17:116:38 | String( ... y.data) |
383-
| tst.js:119:9:119:51 | object | tst.js:120:5:120:10 | object |
384-
| tst.js:119:9:119:51 | object | tst.js:120:5:120:10 | object |
385-
| tst.js:119:18:119:51 | Object. ... taint]) | tst.js:119:9:119:51 | object |
386-
| tst.js:119:36:119:50 | plainObj[taint] | tst.js:119:18:119:51 | Object. ... taint]) |
387-
| tst.js:119:45:119:49 | taint | tst.js:119:36:119:50 | plainObj[taint] |
388369
#select
389370
| lib.js:6:7:6:9 | obj | lib.js:1:43:1:46 | path | lib.js:6:7:6:9 | obj | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | lib.js:1:43:1:46 | path | library input |
390371
| lib.js:15:3:15:14 | obj[path[0]] | lib.js:14:38:14:41 | path | lib.js:15:3:15:14 | obj[path[0]] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | lib.js:14:38:14:41 | path | library input |
@@ -413,4 +394,3 @@ edges
413394
| tst.js:94:5:94:37 | obj[req ... ', '')] | tst.js:94:9:94:19 | req.query.x | tst.js:94:5:94:37 | obj[req ... ', '')] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:94:9:94:19 | req.query.x | user controlled input |
414395
| tst.js:97:5:97:46 | obj[req ... g, '')] | tst.js:97:9:97:19 | req.query.x | tst.js:97:5:97:46 | obj[req ... g, '')] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:97:9:97:19 | req.query.x | user controlled input |
415396
| tst.js:105:5:105:17 | object[taint] | tst.js:102:24:102:37 | req.query.data | tst.js:105:5:105:17 | object[taint] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:102:24:102:37 | req.query.data | user controlled input |
416-
| tst.js:120:5:120:10 | object | tst.js:116:24:116:37 | req.query.data | tst.js:120:5:120:10 | object | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:116:24:116:37 | req.query.data | user controlled input |

0 commit comments

Comments
 (0)