Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2025-01-20 - Command Argument Injection in `std::process::Command`
**Vulnerability:** When passing user-controlled paths (like `source_path` or `disk_path` which derive from `forker_did` and `fork_name`) to `git clone` using `Command::new("git").args(...)`, there's a risk of command argument injection if the paths start with a hyphen (`-`) and aren't prefixed with `--` to signal the end of options.
**Learning:** `git clone` and other git commands interpret arguments starting with `-` as options. If a path begins with `-`, git might interpret it as a flag, leading to unexpected behavior or arbitrary command execution (e.g., via `--upload-pack`).
**Prevention:** To prevent command argument injection when passing user-controlled paths to `std::process::Command` (e.g., for git), always prepend `--` before the paths to signal the end of options, or ensure the paths are absolute so they cannot be interpreted as flags.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/gitlawb-node/src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,7 @@ pub async fn fork_repo(
.args([
"clone",
"--mirror",
"--",
source_path.to_str().unwrap_or(""),
disk_path.to_str().unwrap_or(""),
])
Expand Down
8 changes: 7 additions & 1 deletion crates/gl/src/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ pub async fn run(args: MirrorArgs) -> Result<()> {

println!("Cloning source (this may take a while for large repos)...");
let clone_status = Command::new("git")
.args(["clone", "--mirror", &source, mirror_path.to_str().unwrap()])
.args([
"clone",
"--mirror",
"--",
&source,
mirror_path.to_str().unwrap(),
])
.status()
.context("failed to run git clone β€” is git installed?")?;

Expand Down
Loading