-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Use flow states in cpp/command-line-injection
#8491
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
C++: Use flow states in cpp/command-line-injection
#8491
Conversation
It doesn't - there's a lot of cases with pointer arguments where we have input and output nodes for the pointed-to values that share a location with the argument. |
Good to know. Then the question is, whether it's unique enough for what we're doing here, or whether there's something that better identifies a data flow node. |
Note that in this case it will only be a problem if you have two |
| select sinkAsArgumentIndirection(sinkNode.getNode()), TPathNode1(sourceNode).(MergedPathNode), | ||
| TPathNode2(sinkNode).(MergedPathNode), | ||
| shellCommand(sinkAsArgumentIndirection(sinkNode.getNode()), callChain) and | ||
| concatResult = sinkNode.getState().(ExecState).getSndNode() |
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.
Since you only care about the snd node, there should be no need to record the fst node in the flow state as well.
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.
Indeed. I'm probably unnecessarily conservative there.
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.
I retract my statement. Turns out there is a case where fst does matter. See the test19 I added. When I omit fst, 3 paths instead of 2 paths are reported involving l. 220. The same happens when I move interestingConcatenation from ExecState to isAdditionalTaintStep.
Indeed, also because that + the location is what the user eventually will see. |
And more generally, If the
Yeah, that's probably good enough. A couple of notes on this:
|
|
DCA Wireshark observations without any of the discussed changes around
Also:
|
Updated accordingly.
Is this run on PRs? I didn't explicitly write |
It's only at |
cpp/ql/src/change-notes/2022-03-21-command-line-injection-with-flow-states.md
Outdated
Show resolved
Hide resolved
MathiasVP
left a comment
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.
(I accidentally committed my own suggestion. Sorry about that!)
In any case, this LGTM!
|
The Code Scanning errors are unrelated. So I'll just go ahead and merge this. |
Rework
cpp/command-line-injectionto use flow states. Only thing I'm not sure about is whether the location of a dataflow node uniquely determines the node, which I depend upon: