-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Rust: Add core::fmt::Write models #22390
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
base: redsun82-rust-analyzer-update
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Added data-flow models for `core::fmt::Write`. This may improve detection of vulnerabilities where tainted data is written to a formatted output buffer. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,6 +129,11 @@ extensions: | |
| - ["<core::str>::parse", "Argument[self].Reference", "ReturnValue.Field[core::result::Result::Ok(0)]", "taint", "manual"] | ||
| - ["<core::str>::trim", "Argument[self].Reference", "ReturnValue.Reference", "taint", "manual"] | ||
| - ["<core::str>::to_string", "Argument[self].Reference", "ReturnValue", "taint", "manual"] | ||
| # Fmt | ||
| - ["<_ as core::fmt::Write>::write_fmt", "Argument[0]", "Argument[self].Reference", "taint", "manual"] | ||
| - ["<_ as core::fmt::Write>::write_str", "Argument[0].Reference", "Argument[self].Reference", "taint", "manual"] | ||
| - ["<_ as core::fmt::Write>::write_char", "Argument[0]", "Argument[self].Reference", "taint", "manual"] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to test every single model individually.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will have a semantic merge conflict with #22376.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - ["core::fmt::write", "Argument[1]", "Argument[0].Reference", "taint", "manual"] | ||
| # Ord | ||
| - ["<_ as core::cmp::Ord>::min", "Argument[self,0]", "ReturnValue", "value", "manual"] | ||
| - ["<_ as core::cmp::Ord>::max", "Argument[self,0]", "ReturnValue", "value", "manual"] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| | main.rs:13:10:13:25 | FormatArgsExpr | 1 | | ||
| | main.rs:16:10:16:23 | FormatArgsExpr | 0 | | ||
| | main.rs:19:13:19:36 | FormatArgsExpr | 1 | | ||
| | main.rs:33:25:33:33 | FormatArgsExpr | 1 | | ||
| | main.rs:38:13:38:32 | FormatArgsExpr | 1 | | ||
| | main.rs:39:13:39:32 | FormatArgsExpr | 0 | | ||
| | main.rs:49:5:49:27 | FormatArgsExpr | 1 | | ||
| | main.rs:50:5:50:26 | FormatArgsExpr | 0 | | ||
| | main.rs:51:5:51:25 | FormatArgsExpr | 1 | | ||
| | main.rs:52:5:52:24 | FormatArgsExpr | 0 | | ||
| | main.rs:27:25:27:33 | FormatArgsExpr | 1 | | ||
| | main.rs:38:40:38:46 | FormatArgsExpr | 0 | | ||
| | main.rs:43:52:43:58 | FormatArgsExpr | 0 | | ||
| | main.rs:49:13:49:33 | FormatArgsExpr | 1 | | ||
| | main.rs:54:13:54:33 | FormatArgsExpr | 0 | | ||
| | main.rs:64:5:64:27 | FormatArgsExpr | 1 | | ||
| | main.rs:65:5:65:26 | FormatArgsExpr | 0 | | ||
| | main.rs:66:5:66:25 | FormatArgsExpr | 1 | | ||
| | main.rs:67:5:67:24 | FormatArgsExpr | 0 | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,28 @@ | ||
| #select | ||
| | main.rs:49:5:49:27 | FormatArgsExpr | main.rs:47:19:47:45 | ...::var(...) | main.rs:49:5:49:27 | FormatArgsExpr | Log entry depends on a $@. | main.rs:47:19:47:45 | ...::var(...) | user-provided value | | ||
| | main.rs:50:5:50:26 | FormatArgsExpr | main.rs:47:19:47:45 | ...::var(...) | main.rs:50:5:50:26 | FormatArgsExpr | Log entry depends on a $@. | main.rs:47:19:47:45 | ...::var(...) | user-provided value | | ||
| | main.rs:51:5:51:25 | FormatArgsExpr | main.rs:47:19:47:45 | ...::var(...) | main.rs:51:5:51:25 | FormatArgsExpr | Log entry depends on a $@. | main.rs:47:19:47:45 | ...::var(...) | user-provided value | | ||
| | main.rs:52:5:52:24 | FormatArgsExpr | main.rs:47:19:47:45 | ...::var(...) | main.rs:52:5:52:24 | FormatArgsExpr | Log entry depends on a $@. | main.rs:47:19:47:45 | ...::var(...) | user-provided value | | ||
| | main.rs:64:5:64:27 | FormatArgsExpr | main.rs:62:19:62:45 | ...::var(...) | main.rs:64:5:64:27 | FormatArgsExpr | Log entry depends on a $@. | main.rs:62:19:62:45 | ...::var(...) | user-provided value | | ||
| | main.rs:65:5:65:26 | FormatArgsExpr | main.rs:62:19:62:45 | ...::var(...) | main.rs:65:5:65:26 | FormatArgsExpr | Log entry depends on a $@. | main.rs:62:19:62:45 | ...::var(...) | user-provided value | | ||
| | main.rs:66:5:66:25 | FormatArgsExpr | main.rs:62:19:62:45 | ...::var(...) | main.rs:66:5:66:25 | FormatArgsExpr | Log entry depends on a $@. | main.rs:62:19:62:45 | ...::var(...) | user-provided value | | ||
| | main.rs:67:5:67:24 | FormatArgsExpr | main.rs:62:19:62:45 | ...::var(...) | main.rs:67:5:67:24 | FormatArgsExpr | Log entry depends on a $@. | main.rs:62:19:62:45 | ...::var(...) | user-provided value | | ||
| edges | ||
| | main.rs:47:9:47:15 | tainted | main.rs:49:5:49:27 | FormatArgsExpr | provenance | Sink:MaD:2 | | ||
| | main.rs:47:9:47:15 | tainted | main.rs:50:5:50:26 | FormatArgsExpr | provenance | Sink:MaD:1 | | ||
| | main.rs:47:9:47:15 | tainted | main.rs:51:5:51:25 | FormatArgsExpr | provenance | Sink:MaD:2 | | ||
| | main.rs:47:9:47:15 | tainted | main.rs:52:5:52:24 | FormatArgsExpr | provenance | Sink:MaD:1 | | ||
| | main.rs:47:19:47:45 | ...::var(...) | main.rs:47:19:47:45 | ...::var(...) [Ok] | provenance | Src:MaD:3 | | ||
| | main.rs:47:19:47:45 | ...::var(...) [Ok] | main.rs:47:19:47:65 | ... .unwrap_or_default() | provenance | MaD:4 | | ||
| | main.rs:47:19:47:65 | ... .unwrap_or_default() | main.rs:47:9:47:15 | tainted | provenance | | | ||
| | main.rs:62:9:62:15 | tainted | main.rs:64:5:64:27 | FormatArgsExpr | provenance | Sink:MaD:2 | | ||
| | main.rs:62:9:62:15 | tainted | main.rs:65:5:65:26 | FormatArgsExpr | provenance | Sink:MaD:1 | | ||
| | main.rs:62:9:62:15 | tainted | main.rs:66:5:66:25 | FormatArgsExpr | provenance | Sink:MaD:2 | | ||
| | main.rs:62:9:62:15 | tainted | main.rs:67:5:67:24 | FormatArgsExpr | provenance | Sink:MaD:1 | | ||
| | main.rs:62:19:62:45 | ...::var(...) | main.rs:62:19:62:45 | ...::var(...) [Ok] | provenance | Src:MaD:3 | | ||
| | main.rs:62:19:62:45 | ...::var(...) [Ok] | main.rs:62:19:62:65 | ... .unwrap_or_default() | provenance | MaD:4 | | ||
| | main.rs:62:19:62:65 | ... .unwrap_or_default() | main.rs:62:9:62:15 | tainted | provenance | | | ||
| models | ||
| | 1 | Sink: std::io::stdio::_eprint; Argument[0]; log-injection | | ||
| | 2 | Sink: std::io::stdio::_print; Argument[0]; log-injection | | ||
| | 3 | Source: std::env::var; ReturnValue.Field[core::result::Result::Ok(0)]; environment | | ||
| | 4 | Summary: <core::result::Result>::unwrap_or_default; Argument[self].Field[core::result::Result::Ok(0)]; ReturnValue; value | | ||
| nodes | ||
| | main.rs:47:9:47:15 | tainted | semmle.label | tainted | | ||
| | main.rs:47:19:47:45 | ...::var(...) | semmle.label | ...::var(...) | | ||
| | main.rs:47:19:47:45 | ...::var(...) [Ok] | semmle.label | ...::var(...) [Ok] | | ||
| | main.rs:47:19:47:65 | ... .unwrap_or_default() | semmle.label | ... .unwrap_or_default() | | ||
| | main.rs:49:5:49:27 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:50:5:50:26 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:51:5:51:25 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:52:5:52:24 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:62:9:62:15 | tainted | semmle.label | tainted | | ||
| | main.rs:62:19:62:45 | ...::var(...) | semmle.label | ...::var(...) | | ||
| | main.rs:62:19:62:45 | ...::var(...) [Ok] | semmle.label | ...::var(...) [Ok] | | ||
| | main.rs:62:19:62:65 | ... .unwrap_or_default() | semmle.label | ... .unwrap_or_default() | | ||
| | main.rs:64:5:64:27 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:65:5:65:26 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:66:5:66:25 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| | main.rs:67:5:67:24 | FormatArgsExpr | semmle.label | FormatArgsExpr | | ||
| subpaths |
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.
Do we have a way of getting taint into an
Argumentsstruct?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.
We have test cases along the lines of
format_args!("{}", source()). Do you mean that or something else?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.
Yeah, I see that it somehow works, I'm just curious which model enables taint to get into an
Argumentsstruct.