Skip to content

Conversation

@paldepind
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Sep 30, 2025
let s1 = source_slice(22);
let s2 = s1.to_string();
sink(s2); // $ MISSING: hasTaintFlow=22 - we are not currently able to resolve the `to_string` call above, which comes from `impl<T: fmt::Display + ?Sized> ToString for T`
sink(s2); // $ MISSING: hasTaintFlow=22
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The explanation here was outdated. We actually resolve the call now, but we can't model the method in a blanket implementation.

@paldepind paldepind marked this pull request as ready for review September 30, 2025 13:37
@paldepind paldepind requested a review from a team as a code owner September 30, 2025 13:37
Copilot AI review requested due to automatic review settings September 30, 2025 13:37
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 a taint model for the add operation on String types in Rust. It enables taint tracking to flow through string concatenation operations where tainted data is added to strings.

  • Adds taint flow models for <alloc::string::String as core::ops::arith::Add>::add
  • Updates test expectations to reflect new taint tracking capabilities for string concatenation
  • Fixes previously missed taint flows in SQL injection and other security tests

Reviewed Changes

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

Show a summary per file
File Description
rust/ql/lib/codeql/rust/frameworks/stdlib/lang-alloc.model.yml Adds taint models for String::add operation
rust/ql/test/query-tests/security/CWE-825/AccessAfterLifetime.expected Updates test expectations with new taint model references
rust/ql/test/query-tests/security/CWE-312/CleartextStorageDatabase.expected Updates test expectations with additional taint flows detected
rust/ql/test/query-tests/security/CWE-312/CleartextLogging.expected Updates test expectations with new string concatenation taint flows
rust/ql/test/query-tests/security/CWE-089/sqlx.rs Updates comments from "MISSING" to found alerts for SQL injection cases
rust/ql/test/query-tests/security/CWE-089/SqlInjection.expected Updates test expectations with many new SQL injection flows now detected
rust/ql/test/library-tests/dataflow/strings/main.rs Updates comment to reflect fixed taint flow case
rust/ql/test/library-tests/dataflow/strings/inline-taint-flow.expected Updates test expectations with new taint flows through string concatenation

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Sep 30, 2025
Copy link
Contributor

@geoffw0 geoffw0 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, great results in tests, waiting for DCA...

@paldepind
Copy link
Contributor Author

DCA looks fine to me. There's a ❌ for stage timings, but it doesn't look like an issue to me.

@paldepind paldepind merged commit a359a24 into github:main Oct 1, 2025
19 of 20 checks passed
@paldepind paldepind deleted the rust/string-add-ref branch October 1, 2025 07:38
Comment on lines +49 to +50
- ["<alloc::string::String as core::ops::arith::Add>::add", "Argument[self]", "ReturnValue", "taint", "manual"]
- ["<alloc::string::String as core::ops::arith::Add>::add", "Argument[0].Reference", "ReturnValue", "taint", "manual"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we instead lift this to <_ as core::ops::arith::Add>::add?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we do this as follow-up, we can include other similar traits (e.g. Sub) as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've created an issue for this.

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.

3 participants