-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Add another CWE-825
query
#8173
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++: Add another CWE-825
query
#8173
Conversation
…caped through global variables.
7f2d4e4
to
ea35f56
Compare
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.
Review of the non-query part. I'll look at the query separately.
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.qhelp
Outdated
Show resolved
Hide resolved
cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/test.cpp
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
Someone with more knowledge of CodeQL than me probably also needs to have a look at this. |
…ess.ql Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
…ess.ql Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
…ess.cpp Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
…ess.qhelp Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Thanks a lot for all the comments. I think my |
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.
This looks promising, I have only nitpicks.
I appreciate thorough tests!
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/test.cpp
Show resolved
Hide resolved
cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/test/query-tests/Likely Bugs/Memory Management/UsingExpiredStackAddress/test.cpp
Outdated
Show resolved
Hide resolved
cpp/ql/src/Likely Bugs/Memory Management/UsingExpiredStackAddress.ql
Outdated
Show resolved
Hide resolved
…ess.ql Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
I've been super unlucky with the last two DCA runs:
The third time's the charm (I hope!) 🤞 |
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, assuming third time is a charm when it comes to DCA runs.
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'm also happy with this PR now (DCA pending...)
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 good from a docs PoV. 👍
DCA looks good 🎉. |
This is a new IR-based query that can hopefully serve as a high-precision version of
cpp/stack-address-escape
. Instead of raising an alert on every assignment that writes the address of a local variable in a non-local variable, the query only raises an alert if we find a subsequent load of that global variable after the local variable's function has returned.The query doesn't find a lot of results currently. But all the results that it does find look like true positives to me.