Skip to content

Commit db0ac7b

Browse files
committed
JS: Fix cartesian product in TypeConfusionThroughParameterTampering
1 parent 729cf79 commit db0ac7b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ private class TypeOfTestBarrier extends DataFlow::BarrierGuardNode, DataFlow::Va
4040
TypeOfTestBarrier() { TaintTracking::isTypeofGuard(astNode, _, _) }
4141

4242
override predicate blocks(boolean outcome, Expr e) {
43-
if TaintTracking::isTypeofGuard(astNode, e, ["string", "object"])
44-
then outcome = [true, false] // separation between string/array removes type confusion in both branches
45-
else outcome = astNode.getPolarity() // block flow to branch where value is neither string nor array
43+
exists(string tag |
44+
TaintTracking::isTypeofGuard(astNode, e, tag) and
45+
if tag = ["string", "object"]
46+
then outcome = [true, false] // separation between string/array removes type confusion in both branches
47+
else outcome = astNode.getPolarity() // block flow to branch where value is neither string nor array
48+
)
4649
}
4750
}
4851

0 commit comments

Comments
 (0)