Skip to content

Commit 7e5ea52

Browse files
committed
JS: protyte poluting now treats unknownFlags as potentially good sanitization.
1 parent bb384fd commit 7e5ea52

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Configuration extends TaintTracking::Configuration {
4646
// Replacing with "_" is likely to be exploitable
4747
not replace.getRawReplacement().getStringValue() = "_" and
4848
(
49-
replace.isGlobal()
49+
replace.maybeGlobal()
5050
or
5151
// Non-global replace with a non-empty string can also prevent __proto__ by
5252
// inserting a chunk of text that doesn't fit anywhere in __proto__

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ nodes
195195
| tst.js:130:9:130:19 | req.query.x |
196196
| tst.js:130:9:130:19 | req.query.x |
197197
| tst.js:130:9:130:52 | req.que ... '), '') |
198-
| tst.js:131:5:131:65 | obj[req ... ), '')] |
199-
| tst.js:131:5:131:65 | obj[req ... ), '')] |
200-
| tst.js:131:9:131:19 | req.query.x |
201-
| tst.js:131:9:131:19 | req.query.x |
202-
| tst.js:131:9:131:64 | req.que ... )), '') |
203198
edges
204199
| lib.js:1:38:1:40 | obj | lib.js:6:7:6:9 | obj |
205200
| lib.js:1:38:1:40 | obj | lib.js:6:7:6:9 | obj |
@@ -380,10 +375,6 @@ edges
380375
| tst.js:130:9:130:19 | req.query.x | tst.js:130:9:130:52 | req.que ... '), '') |
381376
| tst.js:130:9:130:52 | req.que ... '), '') | tst.js:130:5:130:53 | obj[req ... ), '')] |
382377
| tst.js:130:9:130:52 | req.que ... '), '') | tst.js:130:5:130:53 | obj[req ... ), '')] |
383-
| tst.js:131:9:131:19 | req.query.x | tst.js:131:9:131:64 | req.que ... )), '') |
384-
| tst.js:131:9:131:19 | req.query.x | tst.js:131:9:131:64 | req.que ... )), '') |
385-
| tst.js:131:9:131:64 | req.que ... )), '') | tst.js:131:5:131:65 | obj[req ... ), '')] |
386-
| tst.js:131:9:131:64 | req.que ... )), '') | tst.js:131:5:131:65 | obj[req ... ), '')] |
387378
#select
388379
| 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 |
389380
| 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 +404,3 @@ edges
413404
| 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 |
414405
| 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 |
415406
| tst.js:130:5:130:53 | obj[req ... ), '')] | tst.js:130:9:130:19 | req.query.x | tst.js:130:5:130:53 | obj[req ... ), '')] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:130:9:130:19 | req.query.x | user controlled input |
416-
| tst.js:131:5:131:65 | obj[req ... ), '')] | tst.js:131:9:131:19 | req.query.x | tst.js:131:5:131:65 | obj[req ... ), '')] | This assignment may alter Object.prototype if a malicious '__proto__' string is injected from $@. | tst.js:131:9:131:19 | req.query.x | user controlled input |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ app.get('/foo', (req, res) => {
128128
let obj = {};
129129
obj[req.query.x.replace(new RegExp('_', 'g'), '')].x = 'foo'; // OK
130130
obj[req.query.x.replace(new RegExp('_', ''), '')].x = 'foo'; // NOT OK
131-
obj[req.query.x.replace(new RegExp('_', unknownFlags()), '')].x = 'foo'; // OK -- Might be okay but it is currently flagged as a problem
131+
obj[req.query.x.replace(new RegExp('_', unknownFlags()), '')].x = 'foo'; // OK
132132
});

0 commit comments

Comments
 (0)