Skip to content

Commit 805fd0b

Browse files
committed
JS: Refine speculative step definition
1 parent 8818fcc commit 805fd0b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,21 @@ predicate defaultImplicitTaintRead(DataFlow::Node node, ContentSet c) {
105105
not optionalStep(node, _, _)
106106
}
107107

108+
private predicate isArgumentToResolvedCall(DataFlow::Node arg) {
109+
exists(DataFlowCall c |
110+
exists(viableCallable(c)) and
111+
isArgumentNode(arg, c, _)
112+
)
113+
}
114+
108115
predicate speculativeTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
109-
exists(DataFlow::CallNode call, DataFlowCall c |
110-
not exists(viableCallable(c)) and
111-
c.asOrdinaryCall() = call and
116+
exists(DataFlow::CallNode call |
112117
node1 = call.getAnArgument() and
113-
node2 = call
118+
node2 = call and
119+
// A given node can appear as argument in more than one call. For example `x` in `fn.call(x)` is
120+
// is argument 0 of the `fn.call` call, but also the receiver of a reflective call to `fn`.
121+
// It is thus not enough to check if `call` has a known target; we nede to ensure that none of the calls
122+
// involving `node1` have a known target.
123+
not isArgumentToResolvedCall(node1)
114124
)
115125
}

javascript/ql/test/library-tests/FlowSummary/DataFlowConsistency.expected

-1
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,3 @@ multipleArgumentCall
199199
| tst.js:266:3:266:6 | map3 | tst.js:266:3:266:36 | map3.fo ... value)) | Multiple calls for argument node. |
200200
lambdaCallEnclosingCallableMismatch
201201
speculativeStepAlreadyHasModel
202-
| tst.js:223:39:223:44 | array4 | tst.js:223:12:223:45 | Array.p ... array4) | dispatch |

0 commit comments

Comments
 (0)