Skip to content

Commit

Permalink
JS: Fix bad join in isOptionallySanitizedEdgeInternal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
asgerf committed Dec 16, 2024
1 parent 947b785 commit e5ae7e0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ module DomBasedXss {
*/
deprecated predicate isOptionallySanitizedEdge = isOptionallySanitizedEdgeInternal/2;

bindingset[call]
pragma[inline_late]
private SsaVariable getSanitizedSsaVariable(HtmlSanitizerCall call) {
call.getAnArgument().asExpr().(VarAccess).getVariable() = result.getSourceVariable()
}

private predicate isOptionallySanitizedEdgeInternal(DataFlow::Node pred, DataFlow::Node succ) {
exists(HtmlSanitizerCall sanitizer |
// sanitized = sanitize ? sanitizer(source) : source;
Expand All @@ -348,7 +354,7 @@ module DomBasedXss {
count(phi.getAnInput()) = 2 and
not a = b and
sanitizer = DataFlow::valueNode(a.getDef().getSource()) and
sanitizer.getAnArgument().asExpr().(VarAccess).getVariable() = b.getSourceVariable()
getSanitizedSsaVariable(sanitizer) = b
|
pred = DataFlow::ssaDefinitionNode(b) and
succ = DataFlow::ssaDefinitionNode(phi)
Expand Down

0 comments on commit e5ae7e0

Please sign in to comment.