-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Interprocedural indirections in DefaultTaintTracking.qll #2737
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
Merged
rdmarsh2
merged 2 commits into
github:master
from
jbj:DefaultTaintTracking-indirect-parameters
Feb 3, 2020
Merged
C++: Interprocedural indirections in DefaultTaintTracking.qll #2737
rdmarsh2
merged 2 commits into
github:master
from
jbj:DefaultTaintTracking-indirect-parameters
Feb 3, 2020
Conversation
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
As a temporary workaround in the `DefaultTaintTracking` library, we funnel flow across calls by conflating pointer and object both at the caller and the callee. The three cases in `adjustedSink` were deleted because they are now covered by the one case for `ReadSideEffectInstruction` in `instructionTaintStep`. When enabling `DefaultTaintTracking`, this commit on top of github#2736 has the effect effect of recovering two lost results: --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected @@ -1,2 +1,4 @@ | overflowdestination.cpp:30:2:30:8 | call to strncpy | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | | overflowdestination.cpp:46:2:46:7 | call to memcpy | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | +| overflowdestination.cpp:53:2:53:7 | call to memcpy | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | +| overflowdestination.cpp:64:2:64:7 | call to memcpy | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | In the internal repo, we recover one lost result. Additionally, there are two queries that gain an extra source for an existing sink. I'll classify that as noise. The new results look like this: foo(argv); // this `argv` is a new source for the sink in `bar` bar(argv); // this `argv` is the existing source for the sink in `bar`
rdmarsh2
approved these changes
Jan 31, 2020
rdmarsh2
reviewed
Jan 31, 2020
Comment on lines
-276
to
-292
or | ||
// For compatibility, send flow from argument read side effects to their | ||
// corresponding argument expression | ||
exists(IndirectReadSideEffectInstruction read | | ||
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and | ||
read.getArgumentDef().getUnconvertedResultExpression() = result | ||
) | ||
or | ||
exists(BufferReadSideEffectInstruction read | | ||
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and | ||
read.getArgumentDef().getUnconvertedResultExpression() = result | ||
) | ||
or | ||
exists(SizedBufferReadSideEffectInstruction read | | ||
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and | ||
read.getArgumentDef().getUnconvertedResultExpression() = result | ||
) |
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.
Will we need to reintroduce this later when we get flow through interprocedural indirections in DataFlow.qll?
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.
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.
As a temporary workaround in the
DefaultTaintTracking
library, we funnel flow across calls by conflating pointer and object both at the caller and the callee.The three cases in
adjustedSink
were deleted because they are now covered by the one case forReadSideEffectInstruction
ininstructionTaintStep
.When enabling
DefaultTaintTracking
, this commit on top of #2736 has the effect effect of recovering two lost results:In the internal repo, we recover one lost result. Additionally, there are two queries that gain an extra source for an existing sink. I'll classify that as noise. The new results look like this: