fixes taint propagation for unmodeled subroutines #1147
Merged
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.
When a subroutine is unmodeled and we introduce taint directly
in the
call-return
method the taint will be attached to atemporary value and never be really used anywhere.
The reason for that is that we attach the taint to a value stored in
the right-hand side of the argument term, but the right-hand side
could be an arbitrary expression, e.g.,
RAX.RDI
orlow:32[RAX]
,etc. Therefore the value stored in the left-hand side of the argument
term is the result of the evaluation of this expression and is never used
afterward, so instead of tainting
RAX
andRDI
which are reallyused by the lifted code, we lift the freshly created
RAX.RDI
value.This is a general problem and this PR doesn't provide the general
solution but enables taint propagation for a specific case when the
right-hand side expression is a simple variable. It used to work
before, because we were ignoring that our arg_terms inserted by the
api pass are ill-typed for architectures where the size of integer
data type is smaller than the size of the machine register. In BAP
2.1.0 we relaxed the interpreter and let it grok ill-typed expressions
by adding coercions, which jumped in our case, since they created a
new coerced value.
This small fix restores the status quo for taint analysis that was
before 2.1.0, but the right solution should be implemented, as it
still doesn't work for more complex expressions.