Rust: Fix FPs from rust/access-after-lifetime-ended#20966
Merged
geoffw0 merged 6 commits intogithub:mainfrom Dec 8, 2025
Merged
Rust: Fix FPs from rust/access-after-lifetime-ended#20966geoffw0 merged 6 commits intogithub:mainfrom
geoffw0 merged 6 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
approved these changes
Dec 5, 2025
Contributor
paldepind
left a comment
There was a problem hiding this comment.
Nice fix, this makes sense to me.
paldepind
requested changes
Dec 5, 2025
rust/ql/lib/codeql/rust/security/AccessAfterLifetimeExtensions.qll
Outdated
Show resolved
Hide resolved
….qll Co-authored-by: Simon Friis Vindum <paldepind@github.com>
paldepind
approved these changes
Dec 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.