From 4160a99c5155102725c8fe109c1a10dcb9c4ef0e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:11:49 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20command=20argument=20injection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added `--` separator before passing user-controlled paths to `git clone` to prevent command argument injection. Deleted temporary scripts. --- .jules/sentinel.md | 4 ++++ crates/gitlawb-node/src/api/repos.rs | 1 + crates/gl/src/mirror.rs | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 00000000..6ad58f8d --- /dev/null +++ b/.jules/sentinel.md @@ -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. diff --git a/crates/gitlawb-node/src/api/repos.rs b/crates/gitlawb-node/src/api/repos.rs index b09cb6da..608374f3 100644 --- a/crates/gitlawb-node/src/api/repos.rs +++ b/crates/gitlawb-node/src/api/repos.rs @@ -2774,6 +2774,7 @@ pub async fn fork_repo( .args([ "clone", "--mirror", + "--", source_path.to_str().unwrap_or(""), disk_path.to_str().unwrap_or(""), ]) diff --git a/crates/gl/src/mirror.rs b/crates/gl/src/mirror.rs index 400d3d45..27cbe84c 100644 --- a/crates/gl/src/mirror.rs +++ b/crates/gl/src/mirror.rs @@ -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?")?; From 68bb2fd3c4c0fa5d323d7e19341650f31a560fdb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 14:30:55 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITIC?= =?UTF-8?q?AL]=20Fix=20command=20argument=20injection=20and=20update=20h2?= =?UTF-8?q?=20crate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added `--` separator before passing user-controlled paths to `git clone` to prevent command argument injection. Also updated `h2` to `0.4.16` to fix cargo audit issues (RUSTSEC-2026-0258). Deleted temporary scripts. --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7050bc6..5d06464b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2630,7 +2630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ab67060fc6b8ef687992d439ca0fa36e7ed17e9a0b16b25b601e8757df720de" dependencies = [ "data-encoding", - "syn 2.0.117", + "syn 1.0.109", ] [[package]] @@ -3002,7 +3002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3542,9 +3542,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.13" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +checksum = "a9f37a958b41b3b19ee2707c06439c0e9e547e847223eb791ecb0cb821c65e27" dependencies = [ "atomic-waker", "bytes", @@ -3863,7 +3863,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.3", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -5431,7 +5431,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2 0.6.3", + "socket2 0.5.10", "thiserror 2.0.18", "tokio", "tracing", @@ -5468,7 +5468,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.3", + "socket2 0.5.10", "tracing", "windows-sys 0.52.0", ] @@ -5900,7 +5900,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -6794,7 +6794,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]]