[dataflowengineoss] Fix JS dataflow FN for captured closures in higher-order callbacks#5947
Open
ZiyaoZh wants to merge 1 commit intojoernio:masterfrom
Open
[dataflowengineoss] Fix JS dataflow FN for captured closures in higher-order callbacks#5947ZiyaoZh wants to merge 1 commit intojoernio:masterfrom
ZiyaoZh wants to merge 1 commit intojoernio:masterfrom
Conversation
…s/passes/reachingdef/DdgGenerator.scala modified: dataflowengineoss/src/main/scala/io/joern/dataflowengineoss/queryengine/SourcesToStartingPoints.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a JavaScript dataflow false negative for higher-order callbacks that capture values from an outer scope, especially when the callback is passed through a static method before its return value reaches a sink.
The covered pattern combines:
Joern handled parts of this pattern individually, but missed the composed flow from the captured value through the callback invocation result.
Problem
The following combined case was missed:
Expected:
__taint_srctosink(result)Root Cause
Two pieces were missing in
dataflowengineoss:Captured closure method references were not included as starting points for identifier sources.
SourcesToStartingPointsexpanded anIdentifierto field/index accesses and first usages inside captured methods, but not to the capturingMethodRefitself.Callback receivers did not contribute to call-result taint.
DdgGenerator.uses(call)only consideredcall.argument.callback(...), the result also depends on the invoked function value itself.Fix
dataflowengineoss/src/main/scala/io/joern/dataflowengineoss/queryengine/SourcesToStartingPoints.scalasoIdentifiersources also include theMethodRefs that capture them.uses(call)indataflowengineoss/src/main/scala/io/joern/dataflowengineoss/passes/reachingdef/DdgGenerator.scalaso callback-style receivers are considered uses when the receiver resolves to aMethodParameterIn.