Skip to content

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 1, 2025

This PR lifts data flow read-steps of ReferenceContent to taint steps, in the same way that we already do for ElementContent. The motivation is the same: If a reference is a taint source, then it should be safe to assume that the data pointed to is tainted as well (as opposed to just the reference itself).

DCA looks fine.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Sep 1, 2025
@hvitved hvitved force-pushed the rust/taint-tracking-implicit-deref-at-sinks branch 2 times, most recently from fb155c4 to bcbf684 Compare September 2, 2025 06:46
@hvitved hvitved changed the title Rust: Implicit deref at sinks for taint tracking Rust: Deref as taint step Sep 2, 2025
@hvitved hvitved force-pushed the rust/taint-tracking-implicit-deref-at-sinks branch from bcbf684 to 5b51bb2 Compare September 2, 2025 06:55
@@ -39,12 +39,6 @@ module HardcodedCryptographicValueConfig implements DataFlow::ConfigSig {
// case like `[0, 0, 0, 0]`)
isSource(node)
}

predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already covered by defaultImplicitTaintRead.

@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 2, 2025
@hvitved hvitved marked this pull request as ready for review September 2, 2025 06:56
@hvitved hvitved requested a review from a team as a code owner September 2, 2025 06:56
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 06:56
Copy link
Contributor

@Copilot 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 enhances Rust taint tracking by extending taint flow through dereferenced references. The main change lifts data flow read-steps of ReferenceContent to taint steps, similar to existing ElementContent handling, ensuring that when a reference is a taint source, the data it points to is also considered tainted.

Key changes:

  • Add reference dereferencing as a taint propagation path
  • Remove redundant allowImplicitRead predicate for reference content
  • Update test expectations to reflect the improved taint tracking behavior

Reviewed Changes

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

Show a summary per file
File Description
rust/ql/lib/codeql/rust/dataflow/internal/TaintTrackingImpl.qll Adds ReferenceContent to taint flow logic alongside ElementContent
rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql Removes allowImplicitRead predicate that is now handled globally
rust/ql/test/query-tests/security/CWE-825/main.rs Updates test annotations and reformats code
rust/ql/test/query-tests/security/CWE-825/AccessAfterLifetime.expected Updates expected test results with new taint flow paths
rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected Updates expected results to include additional taint edges
rust/ql/test/library-tests/dataflow/strings/inline-taint-flow.expected Updates model numbering and flow expectations

@hvitved hvitved requested a review from paldepind September 2, 2025 07:26
Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and makes sense to me.

@hvitved hvitved merged commit 1130595 into github:main Sep 2, 2025
23 checks passed
@hvitved hvitved deleted the rust/taint-tracking-implicit-deref-at-sinks branch September 2, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants