Skip to content

Commit e2af19b

Browse files
committed
JS: Restrict "get" step to Map objects
1 parent 4c9f406 commit e2af19b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ deprecated private class ConcreteMaybeFromProto extends MaybeFromProto {
2424
ConcreteMaybeFromProto() { this = this }
2525
}
2626

27+
/** Gets a data flow node referring to an instance of `Map`. */
28+
private DataFlow::SourceNode mapObject(DataFlow::TypeTracker t) {
29+
t.start() and
30+
result = DataFlow::globalVarRef("Map").getAnInstantiation()
31+
or
32+
exists(DataFlow::TypeTracker t2 | result = mapObject(t2).track(t2, t))
33+
}
34+
35+
/** Gets a data flow node referring to an instance of `Map`. */
36+
private DataFlow::SourceNode mapObject() { result = mapObject(DataFlow::TypeTracker::end()) }
37+
2738
/**
2839
* A taint-tracking configuration for reasoning about unvalidated dynamic method calls.
2940
*/
@@ -67,7 +78,9 @@ module UnvalidatedDynamicMethodCallConfig implements DataFlow::StateConfigSig {
6778
not PropertyInjection::hasUnsafeMethods(read.getBase().getALocalSource())
6879
)
6980
or
70-
exists(DataFlow::SourceNode base, DataFlow::CallNode get | get = base.getAMethodCall("get") |
81+
exists(DataFlow::CallNode get |
82+
get = mapObject().getAMethodCall("get") and
83+
get.getNumArgument() = 1 and
7184
node1 = get.getArgument(0) and
7285
node2 = get
7386
) and

0 commit comments

Comments
 (0)