Skip to content

JS: Diff-informed queries: phase 3 (non-trivial locations) #20078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ module IndirectCommandInjectionConfig implements DataFlow::ConfigSig {
predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(DataFlow::Node node |
isSinkWithHighlight(sink, node) and
result = node.getLocation()
exists(DataFlow::Node highlight | result = highlight.getLocation() |
if isSinkWithHighlight(sink, _)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changed needed?
According to the data flow configuration the sink nodes are exactly those where isSinkWithHighlight(sink, _) holds.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also seems off to me. The change causes getASelectedSinkLocation to contain an entry all data flow nodes. It should be restricted to those that are sinks, which it was to begin with.

Copy link
Contributor Author

@d10c d10c Aug 14, 2025

Choose a reason for hiding this comment

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

Ok, I see. The original query contains:

  if IndirectCommandInjectionConfig::isSinkWithHighlight(sink.getNode(), _)
  then IndirectCommandInjectionConfig::isSinkWithHighlight(sink.getNode(), highlight)
  else highlight = sink.getNode()

which is what this diff does. But isSinkWithHighlight is sink = highlight or isIndirectCommandArgument(sink, highlight), so you can't have not isSinkWithHighlight(sink, _) and highlight = sink). So the original is correct.

then isSinkWithHighlight(sink, highlight)
else highlight = sink
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ module ShellCommandInjectionFromEnvironmentConfig implements DataFlow::ConfigSig
predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(DataFlow::Node node |
isSinkWithHighlight(sink, node) and
result = node.getLocation()
exists(DataFlow::Node highlight | result = highlight.getLocation() |
Copy link
Contributor

Choose a reason for hiding this comment

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

same question.

if isSinkWithHighlight(sink, _)
then isSinkWithHighlight(sink, highlight)
else highlight = sink
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ module EnvValueAndKeyInjectionConfig implements DataFlow::ConfigSig {
)
)
}

predicate observeDiffInformedIncrementalMode() {
none() // can't override location accurately because of secondary use in select.
}
}

module EnvValueAndKeyInjectionFlow = TaintTracking::Global<EnvValueAndKeyInjectionConfig>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module VerifiedDecodeConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof ActiveThreatModelSource }

predicate isSink(DataFlow::Node sink) { sink = verifiedDecode() }

predicate observeDiffInformedIncrementalMode() {
none() // used as secondary config
}
}

module VerifiedDecodeFlow = TaintTracking::Global<VerifiedDecodeConfig>;
Expand Down