Skip to content

Commit 03c6aed

Browse files
committed
JS: Add implicit taint read of array elements
1 parent af3c341 commit 03c6aed

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ predicate defaultTaintSanitizer(DataFlow::Node node) {
6161
bindingset[node]
6262
predicate defaultImplicitTaintRead(DataFlow::Node node, ContentSet c) {
6363
exists(node) and
64-
c = ContentSet::promiseValue()
64+
c = [ContentSet::promiseValue(), ContentSet::arrayElement()]
6565
}

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ legacyDataFlowDifference
3232
| object-bypass-sanitizer.js:35:29:35:36 | source() | object-bypass-sanitizer.js:28:10:28:30 | sanitiz ... bj).foo | only flow with OLD data flow library |
3333
| promise.js:12:20:12:27 | source() | promise.js:13:8:13:23 | resolver.promise | only flow with OLD data flow library |
3434
| sanitizer-guards.js:57:11:57:18 | source() | sanitizer-guards.js:64:8:64:8 | x | only flow with NEW data flow library |
35-
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured | only flow with OLD data flow library |
3635
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x | only flow with NEW data flow library |
36+
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:16:10:16:10 | y | only flow with NEW data flow library |
3737
consistencyIssue
3838
| library-tests/TaintTracking/nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
3939
| library-tests/TaintTracking/stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
@@ -291,7 +291,9 @@ flow
291291
| tst.js:2:13:2:20 | source() | tst.js:48:10:48:22 | new Buffer(x) |
292292
| tst.js:2:13:2:20 | source() | tst.js:51:10:51:31 | seriali ... ript(x) |
293293
| tst.js:2:13:2:20 | source() | tst.js:54:14:54:19 | unsafe |
294+
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
294295
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
296+
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:16:10:16:10 | y |
295297
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |
296298
| xml.js:12:17:12:24 | source() | xml.js:13:14:13:19 | result |
297299
| xml.js:23:18:23:25 | source() | xml.js:20:14:20:17 | attr |

javascript/ql/test/library-tests/TaintTracking/use-use-after-implicit-read.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ function f(x) {
55
function inner() { captured; captured = "sdf"; }
66

77
captured = [source(), "safe", x];
8-
sink(captured); // NOT OK [INCONSISTENCY] - no implicit read of ArrayElement
8+
sink(captured); // NOT OK - implicit read of ArrayElement
99
g.apply(undefined, captured); // with use-use flow the output of an implicit read might flow here
1010

1111
return captured;
1212
}
1313

1414
function g(x, y) {
1515
sink(x); // NOT OK
16-
sink(y); // OK
16+
sink(y); // OK [INCONSISTENCY] - implicit read confuses array index
1717
}

0 commit comments

Comments
 (0)