-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Deref as taint step #20340
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
Rust: Deref as taint step #20340
Conversation
fb155c4
to
bcbf684
Compare
bcbf684
to
5b51bb2
Compare
@@ -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) { |
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.
This is already covered by defaultImplicitTaintRead
.
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 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 |
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.
Looks good and makes sense to me.
This PR lifts data flow read-steps of
ReferenceContent
to taint steps, in the same way that we already do forElementContent
. 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.