Skip to content

Conversation

@paldepind
Copy link
Contributor

This PR is intended to fix false positives for rust/access-invalid-pointer which where exacerbated by #20879.

There's comments in the code, so I hope things make sense.

Note that the change for Default::default could also remove true positives. But right there's just way to many false negatives coming from that.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Dec 1, 2025
@paldepind paldepind force-pushed the rust/invalid-pointer-barriers branch from b569633 to 40f629e Compare December 1, 2025 14:33
@paldepind paldepind marked this pull request as ready for review December 1, 2025 14:50
@paldepind paldepind requested a review from a team as a code owner December 1, 2025 14:50
Copilot AI review requested due to automatic review settings December 1, 2025 14:50
Copilot finished reviewing on behalf of paldepind December 1, 2025 14:53
Copy link
Contributor

Copilot AI left a 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 adds barriers and refines sink definitions to reduce false positives in the rust/access-invalid-pointer query. The changes separate concerns between the AccessInvalidPointer and AccessAfterLifetime queries by giving each its own sink definitions with appropriate restrictions.

  • Adds type-based barriers (numeric, boolean, fieldless enum) to filter out non-pointer types
  • Restricts DereferenceSink in AccessInvalidPointer to only match raw pointer dereferences in unsafe contexts
  • Introduces a DefaultBarrier to handle imprecise Default::default calls that can resolve to null pointer implementations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
rust/ql/src/queries/summary/Stats.qll Adds import for AccessAfterLifetimeExtensions to ensure all query sink extensions are loaded
rust/ql/lib/codeql/rust/security/AccessInvalidPointerExtensions.qll Adds multiple barriers (type-based, NonNull::new, Default::default) and restricts DereferenceSink to unsafe contexts with raw pointer type checks
rust/ql/lib/codeql/rust/security/AccessAfterLifetimeExtensions.qll Refactors Sink from type alias to abstract class and defines its own sink implementations separate from AccessInvalidPointer

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant