-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: wire up models library to DefaultTaintTracking #2657
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
This adds support for arg-to-arg and arg-to-return taint.
@@ -159,18 +161,64 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) { | |||
// This is part of the translation of `a[i]`, where we want taint to flow | |||
// from `a`. | |||
i2.(PointerAddInstruction).getLeft() = i1 | |||
// TODO: robust Chi handling |
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.
Did you mean to remove this TODO 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.
Yes, because I don't think it belongs here. It probably belongs in the IR data-flow library and the IR itself, which means it should be in a Jira ticket -- I've opened CPP-490.
cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll
Outdated
Show resolved
Hide resolved
i2 = any(CallInstruction call | | ||
exists(int indexIn | | ||
modelTaintToReturnValue(call.getStaticCallTarget(), indexIn) and | ||
i1 = call.getPositionalArgument(indexIn) |
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.
Does this also need to account for indirect parameters via IndirectReadSideEffectInstruction
?
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.
Yes it should. I've added three commits to test and implement that functionality. The test I came up with is very contrived since there's almost no flow to indirections without #2667. Hopefully this will be better soon.
There was already a `WriteSideEffectInstruction` class that served as a superclass for all the specific write side effects. This new class serves the same purpose for read side effects.
Until we have better tracking of indirections, these flow rules conflate pointers and their contents.
Can/should we update (I'm not completely clear on the relationship between TaintTracking and DefaultTaintTracking, I think the latter is built on top of the former? Also I note DefaultTaintTracking.qll lacks a comment at the top of the file explaining itself, which is not the fault of this PR but something that ought to be addressed) |
I'd like to have more tests of |
Done: https://git.semmle.com/Semmle/code/pull/36079 and #2688 . (I've not actually added |
The issue for that test is being tested and fixed on PR github#2686. Adding a test here will cause a semantic merge conflict.
Compared to |
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.
Looks like we wired the dataflow models into the AST-based dataflow but not the IR-based dataflow, so that's not caused by these changes. LGTM otherwise.
https://jira.semmle.com/browse/CPP-489