Skip to content

Commit 468a4df

Browse files
asgerferik-krogh
andauthored
Update javascript/ql/lib/semmle/javascript/security/dataflow/TypeConfusionThroughParameterTamperingQuery.qll
Co-authored-by: Erik Krogh Kristensen <[email protected]>
1 parent 5964be4 commit 468a4df

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ class Configuration extends DataFlow::Configuration {
3636

3737
private class TypeOfTestBarrier extends DataFlow::BarrierGuardNode, DataFlow::ValueNode {
3838
override EqualityTest astNode;
39-
private Expr operand;
4039

41-
TypeOfTestBarrier() { astNode.getAnOperand().(TypeofExpr).getOperand() = operand }
40+
TypeOfTestBarrier() { TaintTracking::isTypeofGuard(astNode, _, _) }
4241

4342
override predicate blocks(boolean outcome, Expr e) {
44-
e = operand and
45-
if astNode.getAnOperand().getStringValue() = ["string", "object"]
43+
if TaintTracking::isTypeofGuard(astNode, e, ["string", "object"])
4644
then outcome = [true, false] // separation between string/array removes type confusion in both branches
4745
else outcome = astNode.getPolarity() // block flow to branch where value is neither string nor array
4846
}

0 commit comments

Comments
 (0)