Skip to content

JS: Fix bug causing re-evaluation of cached barriers#17643

Merged
asgerf merged 3 commits intogithub:js/shared-dataflow-branchfrom
asgerf:jss/cached-barriers
Oct 3, 2024
Merged

JS: Fix bug causing re-evaluation of cached barriers#17643
asgerf merged 3 commits intogithub:js/shared-dataflow-branchfrom
asgerf:jss/cached-barriers

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Oct 2, 2024

Fixes a bug that caused cached barriers nodes to be re-evaluated. Specifically, this predicate in TaintTrackingPrivate was re-evaluated due to the cached AdditionalSanitizerGuardNode inheriting from the query-specific SanitizerGuard:

private class SanitizerGuardAdapter extends DataFlow::Node instanceof TaintTracking::AdditionalSanitizerGuardNode {
  ...
}

cached
predicate defaultTaintSanitizer(DataFlow::Node node) {
  node instanceof DataFlow::VarAccessBarrier or
  node = MakeBarrierGuard<SanitizerGuardAdapter>::getABarrierNode() // transitively depends on SanitizerGuardNode
}

The AdditionalSanitizerGuardNode class no longer inherits from SanitizerGuardNode which means its sanitizes/blocks predicates have their own rootdef now.

Update to XSS queries

This revealed a bug in the some of the ported XSS queries in that they didn't explicitly include the shared XSS barrier guards. In many (but not all) cases those barrier guards worked anyway because they shared their this value with an AdditionalBarrierGuard which meant their overrides were in effect (for such this values), even if not explicitly opted into.

This is similar to the old problem with isBarrierGuardNode() not being able to accurately choose a class to include, but only a set of values, and then we get interference from unrelated classes containing that value. Note that this can't happen anymore as queries now have their own BarrierGuardNode root class, but AdditionalSanitizerGuardNode hadn't yet been refactored this way until now.

Evaluation

Evaluation shows a 2% performance improvement, as a result of fixing the cache re-evaluation bug.

The performance impact is more significant for the use-use flow branch, as it needs to do more work with barriers, and this PR is needed to unblock the use-use flow branch.

@github-actions github-actions bot added the JS label Oct 2, 2024
@asgerf asgerf force-pushed the jss/cached-barriers branch from 9ac1019 to 5d2ce17 Compare October 2, 2024 12:44
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Oct 3, 2024
@asgerf asgerf marked this pull request as ready for review October 3, 2024 09:09
@asgerf asgerf requested a review from a team as a code owner October 3, 2024 09:09
@asgerf asgerf requested a review from erik-krogh October 3, 2024 09:10
Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@asgerf asgerf merged commit 72daa98 into github:js/shared-dataflow-branch Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JS no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants