Skip to content

Commit e5ae7e0

Browse files
committed
JS: Fix bad join in isOptionallySanitizedEdgeInternal
This was previously called from isBarrier(node, state) but without restricting the state. The call was therefore moved to isBarrier(node), but this caused some optimisation changes resulting in a bad join.
1 parent 947b785 commit e5ae7e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ module DomBasedXss {
329329
*/
330330
deprecated predicate isOptionallySanitizedEdge = isOptionallySanitizedEdgeInternal/2;
331331

332+
bindingset[call]
333+
pragma[inline_late]
334+
private SsaVariable getSanitizedSsaVariable(HtmlSanitizerCall call) {
335+
call.getAnArgument().asExpr().(VarAccess).getVariable() = result.getSourceVariable()
336+
}
337+
332338
private predicate isOptionallySanitizedEdgeInternal(DataFlow::Node pred, DataFlow::Node succ) {
333339
exists(HtmlSanitizerCall sanitizer |
334340
// sanitized = sanitize ? sanitizer(source) : source;
@@ -348,7 +354,7 @@ module DomBasedXss {
348354
count(phi.getAnInput()) = 2 and
349355
not a = b and
350356
sanitizer = DataFlow::valueNode(a.getDef().getSource()) and
351-
sanitizer.getAnArgument().asExpr().(VarAccess).getVariable() = b.getSourceVariable()
357+
getSanitizedSsaVariable(sanitizer) = b
352358
|
353359
pred = DataFlow::ssaDefinitionNode(b) and
354360
succ = DataFlow::ssaDefinitionNode(phi)

0 commit comments

Comments
 (0)