-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: add dataflow barrier for if(!x) #2778
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
Conversation
Given that I added a barrier for all DataFlow configurations, we will need a thorough evaluation. But I would prefer some feedback before i start that evaluation. |
I agree that this should be the default behavior for taint-tracking configurations 👍 For general data-flow configurations I'm not so sure. For example, CorMisconfigurationForCredentials actually tracks Another way to handle this which we've talked about is to block all nodes that the type inference has inferred to be falsy. So the way to "opt out" might one day be to make it configurable which abstract values you want to track/block. (This is on the JS2020 list and I'm still hoping to get around to it). In the meantime, I'd suggest making this the default for taint-tracking configurations and expose a nice way to opt-in for data-flow configurations. |
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, other LGTM. 👍
Co-Authored-By: Asger F <[email protected]>
Evaluation came back bad, I'll look into it. |
Seems like the bad evaluation was due to the misoptimization in PrototypePollutionUtility that got fixed in #2779. I'm running another evaluation. |
The evaluation (part2) is looking like the performance hit is too great for the benefit we get. There is 1 instance of |
An evaluation over the weekend looks good in terms of performance, except |
Maybe we should try the same solution I used in PrototypePollutionUtility, in which the guard node for |
I've done this now, and performance seems fine from a first look (I forgot --dpm on that run, and performance was ±10%, so I'm redoing with --dpm). Although I don't fancy the |
Performance with --dpm looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! A few nits otherwise LGTM.
@@ -355,6 +355,11 @@ module TaintedPath { | |||
} | |||
} | |||
|
|||
/** | |||
* A check of the form `if(x)`, which sanitizes `x` in its "else" branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Could you make the class private?
Co-Authored-By: Asger F <[email protected]>
Consider the example:
Previously we would detect flow from
source
tosink
, as it can pass unsanitized through the "else" branch of the if.Looking at how to solve this I encountered a barrier that @asgerf wrote in
PrototypePollutionUtility.ql
that solved the exact issue.I moved that barrier into an
AdditionalBarrierGuardNode
that works for all DataFlow configurations.(It looks very different when moved from
isBarrier
to aAdditionalBarrierGuardNode
, but it does the same thing).