-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: TaintedPath query #18960
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
Merged
Merged
Rust: TaintedPath query #18960
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8223dde
Rust: TaintedPath query
aibaars 4b5883a
Add a bit of modelling
aibaars 0fd69ea
Add QL test
aibaars ecca805
Rust: add Dataflow::BarrierGuard module
aibaars f08d1d1
Rust: tainted path implement basic sanitizers
aibaars a3cc695
Rust: update integration test output
aibaars 81f954a
Rust: add missing QLDocs
aibaars d3e2877
Rust/Python improve qldoc of SafeAccessCheck
aibaars 5a91b94
Refactor using OptionalStep
aibaars 2804c13
Rust: use optionalBarrier
aibaars f5fe531
Rust: remove Stage::ref() trick
aibaars efedfa1
Rust: move optionalStep/Barrier predicates into Cached module
aibaars b10a296
Rust: add more path-injection sinks
aibaars bf76505
Rust: address comments
aibaars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Provides modeling for the `Poem` library. | ||
| */ | ||
|
|
||
| private import rust | ||
| private import codeql.rust.Concepts | ||
| private import codeql.rust.dataflow.DataFlow | ||
|
|
||
| /** | ||
| * Parameters of a handler function | ||
| */ | ||
| private class PoemHandlerParam extends RemoteSource::Range { | ||
| PoemHandlerParam() { | ||
| exists(TupleStructPat param | | ||
| param.getResolvedPath() = ["crate::web::query::Query", "crate::web::path::Path"] | ||
| | | ||
| this.asPat().getPat() = param.getAField() | ||
geoffw0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * Provides classes modeling security-relevant aspects of the standard libraries. | ||
| */ | ||
|
|
||
| private import rust | ||
| private import codeql.rust.Concepts | ||
| private import codeql.rust.controlflow.ControlFlowGraph as Cfg | ||
| private import codeql.rust.controlflow.CfgNodes as CfgNodes | ||
| private import codeql.rust.dataflow.DataFlow | ||
|
|
||
| /** | ||
| * A call to the `starts_with` method on a `Path`. | ||
| */ | ||
| private class StartswithCall extends Path::SafeAccessCheck::Range, CfgNodes::MethodCallExprCfgNode { | ||
| StartswithCall() { | ||
| this.getAstNode().(Resolvable).getResolvedPath() = "<crate::path::Path>::starts_with" | ||
| } | ||
|
|
||
| override predicate checks(Cfg::CfgNode e, boolean branch) { | ||
| e = this.getReceiver() and | ||
| branch = true | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/rust-all | ||
| extensible: sourceModel | ||
| data: [] | ||
| - addsTo: | ||
| pack: codeql/rust-all | ||
| extensible: sinkModel | ||
| data: | ||
| - ["lang:std", "crate::fs::copy", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::copy", "Argument[1]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::create_dir", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::create_dir_all", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::hard_link", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::hard_link", "Argument[1]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::metadata", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::read", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::read_dir", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::read_link", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::read_to_string", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::remove_dir", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::remove_dir_all", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::remove_file", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::rename", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::rename", "Argument[1]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::set_permissions", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::soft_link", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::soft_link", "Argument[1]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::symlink_metadata", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "crate::fs::write", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::DirBuilder>::create", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::File>::create", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::File>::create_buffered", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::File>::create_new", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::File>::open", "Argument[0]", "path-injection", "manual"] | ||
| - ["lang:std", "<crate::fs::File>::open_buffered", "Argument[0]", "path-injection", "manual"] | ||
|
|
||
| - addsTo: | ||
| pack: codeql/rust-all | ||
| extensible: summaryModel | ||
| data: | ||
| - ["lang:std", "<crate::path::PathBuf as crate::convert::From>::from", "Argument[0]", "ReturnValue", "taint", "manual"] | ||
| - ["lang:std", "<crate::path::Path>::join", "Argument[self]", "ReturnValue", "taint", "manual"] | ||
| - ["lang:std", "<crate::path::Path>::join", "Argument[0]", "ReturnValue", "taint", "manual"] | ||
| - ["lang:std", "<crate::path::Path>::canonicalize", "Argument[self].OptionalStep[normalize-path]", "ReturnValue.Field[crate::result::Result::Ok(0)]", "taint", "manual"] | ||
| - ["lang:std", "<crate::path::Path>::canonicalize", "Argument[self].OptionalBarrier[normalize-path]", "ReturnValue.Field[crate::result::Result::Ok(0)]", "taint", "manual"] |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.