Skip to content

Commit 3b09bc5

Browse files
committed
JS: Add taint step for shift()
1 parent 3ea1134 commit 3b09bc5

File tree

2 files changed

+12
-0
lines changed
  • javascript/ql

2 files changed

+12
-0
lines changed

javascript/ql/lib/semmle/javascript/internal/flow_summaries/Arrays.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ class Shift extends SummarizedCallable {
486486
preservesValue = true and
487487
input = "Argument[this].ArrayElement[0]" and
488488
output = "ReturnValue"
489+
or
490+
// ArrayElement[0] is not automatically converted to a taint step, so add it manually
491+
preservesValue = false and
492+
input = "Argument[this]" and
493+
output = "ReturnValue"
489494
}
490495
}
491496

javascript/ql/test/library-tests/TripleDot/arrays.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ function shiftUnknown() {
1313
sink(array.shift()); // $ hasValueFlow=shift.unkn
1414
sink(array.shift()); // $ hasValueFlow=shift.unkn
1515
}
16+
17+
function shiftTaint() {
18+
const array = source('shift.directly-tainted');
19+
sink(array.shift()); // $ hasTaintFlow=shift.directly-tainted
20+
sink(array.shift()); // $ hasTaintFlow=shift.directly-tainted
21+
sink(array.shift()); // $ hasTaintFlow=shift.directly-tainted
22+
}

0 commit comments

Comments
 (0)