Skip to content

Commit a3e4e62

Browse files
committed
Removed taint from ArrayBuffer constructor as it accepts length
1 parent 4bc3e9e commit a3e4e62

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@ private class ArrayBufferEntryPoint extends API::EntryPoint {
7474
pragma[nomagic]
7575
API::Node arrayBufferConstructorRef() { result = any(ArrayBufferEntryPoint a).getANode() }
7676

77-
class ArrayBufferConstructorSummary extends SummarizedCallable {
78-
ArrayBufferConstructorSummary() { this = "ArrayBuffer constructor" }
79-
80-
override DataFlow::InvokeNode getACall() {
81-
result = arrayBufferConstructorRef().getAnInstantiation()
82-
}
83-
84-
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
85-
preservesValue = true and
86-
input = "Argument[0].ArrayElement" and
87-
output = "ReturnValue.ArrayElement"
88-
}
89-
}
90-
9177
class TransferLike extends SummarizedCallable {
9278
TransferLike() { this = "ArrayBuffer#transfer" }
9379

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ legacyDataFlowDifference
4040
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr | only flow with NEW data flow library |
4141
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z | only flow with NEW data flow library |
4242
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:18:10:18:12 | sub | only flow with NEW data flow library |
43-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:22:10:22:13 | view | only flow with NEW data flow library |
44-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:26:10:26:14 | view1 | only flow with NEW data flow library |
45-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView | only flow with NEW data flow library |
46-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 | only flow with NEW data flow library |
47-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str | only flow with NEW data flow library |
48-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:13 | str2 | only flow with NEW data flow library |
43+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:48:10:48:12 | str | only flow with NEW data flow library |
44+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:52:10:52:13 | str2 | only flow with NEW data flow library |
4945
| 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 |
5046
consistencyIssue
5147
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
5248
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
5349
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
54-
| typed-arrays.js:40 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
50+
| typed-arrays.js:23 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
51+
| typed-arrays.js:28 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
52+
| typed-arrays.js:32 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
53+
| typed-arrays.js:36 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
54+
| typed-arrays.js:42 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
5555
flow
5656
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5757
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -342,12 +342,8 @@ flow
342342
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr |
343343
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z |
344344
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:18:10:18:12 | sub |
345-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:22:10:22:13 | view |
346-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:26:10:26:14 | view1 |
347-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView |
348-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 |
349-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str |
350-
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:13 | str2 |
345+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:48:10:48:12 | str |
346+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:52:10:52:13 | str2 |
351347
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
352348
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
353349
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

javascript/ql/test/library-tests/TaintTracking/typed-arrays.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ function test() {
1717
const sub = y.subarray(1, 3)
1818
sink(sub); // NOT OK
1919

20-
const buffer = new ArrayBuffer(x);
20+
const buffer = new ArrayBuffer(8);
2121
const view = new Uint8Array(buffer);
22-
sink(view); // NOT OK
22+
view.set(x, 3);
23+
sink(buffer); // NOT OK -- Should be flagged but it is not.
2324

24-
const sharedBuffer = new SharedArrayBuffer(x);
25+
const sharedBuffer = new SharedArrayBuffer(8);
2526
const view1 = new Uint8Array(sharedBuffer);
26-
sink(view1); // NOT OK
27+
view1.set(x, 3);
28+
sink(sharedBuffer); // NOT OK -- Should be flagged but it is not.
2729

2830
const transfered = buffer.transfer();
2931
const transferedView = new Uint8Array(transfered);
30-
sink(transferedView); // NOT OK
32+
sink(transferedView); // NOT OK -- Should be flagged but it is not.
3133

3234
const transfered2 = buffer.transferToFixedLength();
3335
const transferedView2 = new Uint8Array(transfered2);
34-
sink(transferedView2); // NOT OK
36+
sink(transferedView2); // NOT OK -- Should be flagged but it is not.
3537

3638
var typedArrayToString = (function () {
3739
return function (a) { return String.fromCharCode.apply(null, a); };

0 commit comments

Comments
 (0)