Rust: Fix FPs in rust/hard-coded-cryptographic-value#22053
Open
geoffw0 wants to merge 5 commits into
Open
Conversation
…graphic-value (including string concatenation).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Rust rust/hard-coded-cryptographic-value query’s dataflow configuration to reduce false positives when hard-coded constants are combined with non-constant data via arithmetic/bitwise operations (and +/+=-style string concatenation), and updates the associated tests and change note.
Changes:
- Add a new barrier for arithmetic/bitwise operations to stop “hard-coded” flow across these operations.
- Update the CWE-798 Rust query test to ensure arithmetic-with-variable no longer triggers alerts and to cover string append scenarios.
- Add a change note documenting the analysis behavior change.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/query-tests/security/CWE-798/test_heuristic.rs | Updates inline expectations to assert the FP fix and adds string append test cases. |
| rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected | Regenerates expected output reflecting the new barrier behavior/models. |
| rust/ql/src/change-notes/2026-06-25-hard-coded-cryptographic-value-arithmetic-barrier.md | Adds a change note for the query behavior change. |
| rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll | Introduces a new barrier node class for arithmetic/bitwise operations. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 1
hvitved
requested changes
Jun 25, 2026
…tensions.qll Co-authored-by: Tom Hvitved <hvitved@github.com>
Contributor
Author
|
Change suggestions accepted. I will need to check the DCA run still. |
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.
Addresses a common source of false positive results in
rust/hard-coded-cryptographic-valuewhere arithmetic involves constants but the result is not constant. For example: