-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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++: Improve and promote cpp/overflow-buffer #18837
Conversation
…so it will appear in security-extended.
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.
PR Overview
This PR improves and promotes the "Call to memory access function may overflow buffer" query by fixing its handling of array expressions within offsetof and adjusting its severity and precision for the security-extended suite.
- Updated change note in cpp/ql/src documenting the security-extended promotion of cpp/overflow-buffer.
- Added a change note in cpp/ql/lib for fixing the getBufferSize predicate issue.
Reviewed Changes
File | Description |
---|---|
cpp/ql/src/change-notes/2025-02-20-overflow-buffer.md | Added change note to promote cpp/overflow-buffer to security-extended. |
cpp/ql/lib/change-notes/2025-02-20-getbuffersize.md | Documented the fix for getBufferSize misinterpreting array expressions. |
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
Did you look at the results flagged up by DCA and their quality? |
DCA
|
I think this is ready to merge, but I'd really appreciate a second opinion on at least some of the real world results. |
This is what I'm seeing:
|
…for arrays inside classes (though it sometimes fails, costing us TPs).
Thanks for taking a look.
I've just pushed a change that fixes this FP result in PHP (amongst others), and the cost of losing some TPs as well. I think this is a good tradeoff given the query is a bit noisy, and one we could improve in future by refining the existing
The hashing ones are also eliminated by the commit I just pushed (the clear TP result remains). |
This was caused by a variable with multiple types in the database. Probably shouldn't happen, but I've hardened the query to this. I should do another DCA run now with all the changes... [started] |
One of the tests is from the internal repo so I'm moving it to here before accepting the differences. I think I'll also need to merge main (after the old copy of the test is deleted) before all tests actually pass here... |
Thanks for the fixes. I'm happy with this once DCA comes showing that we no longer unexpectedly lose or gain results. |
Hmm, I'm still seeing some cases with negative sizes in the latest DCA run. :( |
Shall we just back out the changes from 1354beb (and the fix you did on top of that)? |
…roduce negative numbers now.
My Friday brain appears to have come up with an "obvious" better solution, so we'll see how we do with that. The problem with backing out the changes is having spend time looking into the results I'm not really sure any more that the query should be promoted without both improvements. So that leaves us with the |
DCA
TL;DR: not perfect but should be an improvement for users of the query. |
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.
Happy that everything looks ok now.
Improve and promote "Call to memory access function may overflow buffer" (
cpp/overflow-buffer
).offsetof
expressions were being misinterpreted as accesses.security-extended
(by increasing the severity towarning
and setting the precision tomedium
).high
precision (code scanning suite) at some point, we will probably need to do something with these.