Skip to content

Commit 6e441b5

Browse files
paldepindCopilot
andcommitted
Rust: Distinguish taint and value flow in String::from
The regenerated String::from summary treats the whole argument as value-preserving. That is too strong for borrowed string conversions: the resulting owned String carries the input contents, but is not the same dataflow value as the borrowed input. Override this with whole-argument taint flow and explicit Cow variants. Moving the String out of Cow::Owned preserves its value, whereas Cow::Borrowed requires taint flow from the referenced contents. Keep both Cow paths because manual summaries replace the generated alternatives. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 786f0f17-6512-4098-8c92-7721e13b78b2
1 parent f831da9 commit 6e441b5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎rust/ql/lib/codeql/rust/frameworks/stdlib/alloc.model.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
["<alloc::string::String>::as_str", "Argument[self].Reference", "ReturnValue.Reference", "taint", "manual"],
6363
["<alloc::string::String>::as_bytes", "Argument[self].Reference", "ReturnValue.Reference.Element", "taint", "manual"],
6464
["<alloc::string::ToString>::to_string", "Argument[self].Reference", "ReturnValue", "taint", "manual"],
65+
["<alloc::string::String as core::convert::From>::from", "Argument[0]", "ReturnValue", "taint", "manual"],
66+
["<alloc::string::String as core::convert::From>::from", "Argument[0].Field[alloc::borrow::Cow::Owned(0)]", "ReturnValue", "value", "manual"],
67+
["<alloc::string::String as core::convert::From>::from", "Argument[0].Field[alloc::borrow::Cow::Borrowed(0)].Reference", "ReturnValue", "taint", "manual"],
6568
// Overwrite generated model
6669
["<alloc::string::String as core::ops::arith::Add>::add", "Argument[self]", "ReturnValue", "taint", "manual"],
6770
["<alloc::string::String as core::ops::arith::Add>::add", "Argument[0].Reference", "ReturnValue", "taint", "manual"],

0 commit comments

Comments
 (0)