-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Fix FPs from rust/access-after-lifetime-ended #20966
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR fixes false positives in the rust/access-after-lifetime-ended security query by improving its handling of trait method calls that use generic type parameters.
- Modified the dataflow analysis to consider runtime targets in addition to static targets for function calls
- Added comprehensive test coverage for generic trait method calls to prevent regressions
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
rust/ql/lib/codeql/rust/security/AccessAfterLifetimeExtensions.qll |
Updated mayEncloseOnStack predicate to include runtime targets alongside static targets, enabling proper tracking through generic trait method calls |
rust/ql/test/query-tests/security/CWE-825/lifetime.rs |
Added new test case demonstrating safe pointer usage through generic trait methods |
rust/ql/test/query-tests/security/CWE-825/main.rs |
Added call to the new test function |
rust/ql/test/query-tests/security/CWE-825/AccessAfterLifetime.expected |
Updated expected test output with new edges and nodes for the generic test case |
rust/ql/src/change-notes/2025-12-04-access-after-lifetime-ended.md |
Added release note documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
paldepind
left a comment
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.
Nice fix, this makes sense to me.
rust/ql/lib/codeql/rust/security/AccessAfterLifetimeExtensions.qll
Outdated
Show resolved
Hide resolved
….qll Co-authored-by: Simon Friis Vindum <paldepind@github.com>
Fix FPs from
rust/access-after-lifetime-endedinvolving calls to trait methods using generic parameters (so there is no single static target).MRVA-100 results look very promising and may justify increasing the query to
@precision high. I'll do DCA and MRVA-1000 runs to verify. --- on the MRVA-1000 we go from 998 results to 61; the "before" results are dense with the issue we fix here, while the "after" results are not perfect, but much better.