Skip to content

Rust: Do not treat account identifiers as sensitive in cleartext queries - #22981

Open
LucaCappelletti94 wants to merge 2 commits into
github:mainfrom
LucaCappelletti94:upstream/rust-cleartext-storage-id
Open

LucaCappelletti94 wants to merge 2 commits into
github:mainfrom
LucaCappelletti94:upstream/rust-cleartext-storage-id

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Rust's cleartext logging, storage and transmission queries report any value whose name looks like an account identifier, such as user_id, username or anything containing uuid. For example, writing a variable named user_uuid to a log is reported as cleartext logging of sensitive data.

The same queries for JavaScript, Python, Ruby and Swift do not treat account identifiers as sensitive, and neither does Rust's own rust/weak-sensitive-data-hashing. This PR makes the three Rust cleartext queries ignore them too. A value whose name also suggests a password, such as account_password, is still reported.

Names like session_key and account_key were classified only as account identifiers, so the shared heuristics now classify them as secrets and they stay reported in every language.

Copilot AI auto review requested due to automatic review settings November 2, 2026 13:59
@LucaCappelletti94
LucaCappelletti94 requested a review from a team as a code owner November 2, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The account-identifier filters also exclude credential-like names such as session_key and account_key, suppressing cleartext leak detection in logging, database storage, and transmission.

1 open issue
What changed in this PR

This PR reduces account-identifier false positives in Rust’s cleartext security queries while preserving password detection.

Changes:

  • Filters identifier-classified sources from logging, database storage, and transmission queries.
  • Adds regression cases for ignored identifiers and retained password alerts, with updated expected results.
  • Documents the analysis change.
File Description
rust/​ql/​test/​query-tests/​security/​CWE-312/​test_storage.rs Adds identifier and password database-storage cases.
rust/​ql/​test/​query-tests/​security/​CWE-312/​test_logging.rs Adds identifier and password logging cases.
rust/​ql/​test/​query-tests/​security/​CWE-312/​CleartextStorageDatabase.expected Updates expected storage alerts and paths.
rust/​ql/​test/​query-tests/​security/​CWE-312/​CleartextLogging.expected Updates expected logging alerts and paths.
rust/​ql/​test/​query-tests/​security/​CWE-311/​main.rs Adds identifier and password transmission cases.
rust/​ql/​test/​query-tests/​security/​CWE-311/​CleartextTransmission.expected Records the new password transmission alert.
rust/​ql/​src/​change-notes/​2026-11-02-cleartext-account-identifiers.md Documents reduced account-identifier reporting.
rust/​ql/​lib/​codeql/​rust/​security/​CleartextTransmissionExtensions.qll Filters identifier-classified transmission sources.
rust/​ql/​lib/​codeql/​rust/​security/​CleartextStorageDatabaseExtensions.qll Filters identifier-classified database-storage sources.
rust/​ql/​lib/​codeql/​rust/​security/​CleartextLoggingExtensions.qll Filters identifier-classified logging sources.

Review effort: Max (auto)

private class SensitiveDataAsSource extends Source instanceof SensitiveData { }
private class SensitiveDataAsSource extends Source instanceof SensitiveData {
SensitiveDataAsSource() {
SensitiveData.super.getClassification() != SensitiveDataClassification::id()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

session_key, sessionkey, account_key and accnt_key are now classified as secrets in the shared heuristics, so the three Rust queries still report them. The Rust sensitive data test and a new session_key case in the logging test cover this. JavaScript, Python, Ruby and Swift already excluded id, so they now report these names too.

@github-actions github-actions Bot added documentation Rust Pull requests that update Rust code external-contribution labels Nov 2, 2026
@LucaCappelletti94
LucaCappelletti94 requested a review from a team as a code owner November 2, 2026 15:40

This branch has not been deployed

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

Labels

documentation external-contribution Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants