Skip to content

Commit 9502869

Browse files
committed
improve join-order for aliasPropertyPresenceStep
1 parent fee7ce6 commit 9502869

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/UnsafeJQueryPlugin.qll

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,27 @@ module UnsafeJQueryPlugin {
6262
* With this taint-step we regain that `foo.bar` is tainted, because `PropertyPresenceSanitizer` could remove it.
6363
*/
6464
private predicate aliasPropertyPresenceStep(DataFlow::Node src, DataFlow::Node sink) {
65-
exists(PropertyPresenceSanitizer sanitizer, DataFlow::PropRead read | read = src |
66-
read = sanitizer.getPropRead() and
67-
sink = AccessPath::getAnAliasedSourceNode(read) and
68-
read.getBasicBlock().(ReachableBasicBlock).strictlyDominates(sink.getBasicBlock())
65+
exists(ReachableBasicBlock srcBB, ReachableBasicBlock sinkBB |
66+
aliasPropertyPresenceStepHelper(src, sink, srcBB, sinkBB) and
67+
srcBB.strictlyDominates(sinkBB)
68+
)
69+
}
70+
71+
/**
72+
* Holds if there is a taint-step from `src` to `sink`, and `srcBB` is the basicblock for `src` and `sinkBB` is the basicblock for `sink`.
73+
*
74+
* This predicate is outlined to get a better join-order.
75+
*/
76+
pragma[noinline]
77+
private predicate aliasPropertyPresenceStepHelper(
78+
DataFlow::PropRead src, DataFlow::Node sink, ReachableBasicBlock srcBB,
79+
ReachableBasicBlock sinkBB
80+
) {
81+
exists(PropertyPresenceSanitizer sanitizer |
82+
src = sanitizer.getPropRead() and
83+
sink = AccessPath::getAnAliasedSourceNode(src) and
84+
srcBB = src.getBasicBlock() and
85+
sinkBB = sink.getBasicBlock()
6986
)
7087
}
7188
}

0 commit comments

Comments
 (0)