-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Avoid partial chi flow to struct/class #3219
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++: Avoid partial chi flow to struct/class #3219
Conversation
Flow through partial chi-instruction operands was introduced to make definition-by-reference work, but its implementation also allowed all other partial writes to propagate. In particular, tainting a field would taint the whole struct, which in turn led to taint propagating across unrelated fields of a struct. The security test `CWE-134/semmle/argv/argvLocal.c` shows that we also want to propagate taint from an array element to the whole array, and it also seems right to propagate taint from a union member to the whole union.
Started https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/1021/ I'm hoping this will remove the FPs we have on git/git in (at least) |
The |
t instanceof ArrayType | ||
or | ||
// Buffers or unknown size | ||
t instanceof UnknownType |
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.
For a struct pointer parameter, I think its chi nodes will have UnknownType
. How can we find the struct type?
These are the result differences:
I've looked through the path explanations for all three queries on both projects, and I'll claim that all the lost results are FPs due to field conflation, while all the remaining results are TPs (in the sense that the query is working as it's designed to work). |
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.
LGTM
Taint through partial chi-instruction operands was introduced to make definition-by-reference work, but its implementation also allowed all other partial writes to propagate. In particular, tainting a field would taint the whole struct, which in turn led to taint propagating across unrelated fields of a struct.
The security test
CWE-134/semmle/argv/argvLocal.c
shows that we also want to propagate taint from an array element to the whole array, and it also seems right to propagate taint from a union member to the whole union.