Repository navigation
harden(cloud/git): curl/wget flag-injection gate + git exit-code propagation (#100 G4) - #107
Merged
Merged
Conversation
Audit group G4 from the full-codebase audit (#100): two CRITICAL flag-injection holes plus exit-code, secret-leak and lossy-conversion findings in the git and cloud command filters. CRITICAL 1 — curl attached-value flag injection (curl_cmd / utils): the deny-list matched `-K` / `--config` as bare tokens but not the attached-value form `-K=file` / `--config=file`, which curl accepts. Added `option_key()` to normalise each arg (strip dashes, split on `=`, take the key) before the deny check; `-K=file` and `--config=file` are now rejected. CRITICAL 2 — wget unguarded file read/write flags (wget_cmd / utils): the gate did not block `--output-document` / `-O` (arbitrary file overwrite), `--input-file` / `-i` (arbitrary file read), or `--load-cookies` (cookie-theft pivot) in any form. Added all three to the deny-list with the same attached-value normalisation; bare, space-separated and `=`-attached shapes all rejected. IMPORTANT 3 — psql DSN password leak: verbose mode logged the raw psql argv, which can carry a DSN with an inline password. The verbose log now runs the argv through `scrub_secrets` first. IMPORTANT 4 — git diff `--` mis-placement: `normalize_diff_args` could demote a revision to a pathspec on unusual arg ordering. Added a defensive ordering check — if any arg after the path-start still looks like a revision, skip injection and let git resolve the args. IMPORTANT 5 — git exit code absorbed: `run_status` (compact), `run_stash` (list/show) and `run_worktree` (list) applied the output filter before checking git's exit code, so a non-zero git exit was swallowed. All three now check `result.success()` and propagate the real exit code with raw output on failure. IMPORTANT 6 — gt non-UTF-8 arg mangling: `run_other` did `to_string_lossy()` on all args before forwarding unknown `gt` subcommands to git. The passthrough path now keeps `OsStr`/`OsString` end-to-end; only the recognised-subcommand branches stringify. NICE 7/8 — rebrand stale `rtk` strings to `contextcrawler` in the git diff-truncation hint and the docker/kubectl logs usage banners; pruned the now-dead branding-lint allowlist entries. Tests: curl `-K=file`/`--config=file` rejection, wget `-O`/`-i`/ `--load-cookies` rejection in every shape, psql DSN scrubbing, and git exit-code propagation for status/stash/worktree. cargo test --workspace 2309 passed, 6 ignored; release build clean, no new warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…value bypass + post-`--` false positive The first G4/#100 fix added `option_key()`, which only stripped a leading dash and split on `=`. It missed two short-flag bypass shapes: - attached short values: `-Kfile` (curl), `-Ofile` (wget) — value attached with no `=` and no space; `option_key` returned `Kfile`, never matched. - short-flag bundling: `-sK` / `-sKfile` — curl/wget bundle short flags, so `-sK` means `-s` then `-K`; `option_key` returned `sK`. Replace `option_key` with two helpers: - `long_option_key` — long flags only (`--config[=file]`), `=`-split key. - `short_token_has_forbidden` — char-scans a single-dash token; any forbidden short flag anywhere in the bundle rejects. Conservative and correct because forbidden short flags (`K`; `O`/`i`/`e`) are value-taking, so the trailing chars are an opaque value once one is hit. Also fix a false positive: the check was context-free, so a literal `-K` operand after a `--` separator was wrongly rejected. Both curl and wget checks are now separator-aware — a bare `--` stops the flag check. Tests cover every bypass (`-Kfile`, `-sK`, `-sKfile`, `-Ofile`, `-iurls.txt`, `-qO`), the post-`--` false positive, and a benign bundle (`-sL`). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ss + value-flag false positive Finding 1 (real bypass): curl/wget use GNU getopt_long, which accepts any unambiguous prefix of a long option — `--conf=file` invokes `--config`, `--out=x` invokes `--output-document`. The exact-match deny-list was bypassed by every abbreviation. New `long_key_matches_forbidden` rejects a key when it is a prefix of any forbidden long name (`F.starts_with(key)`); over-rejects short ambiguous abbreviations, which is the safe direction. Finding 2 (false positive): a `-`-looking VALUE of a separate-value flag (`curl --data -K`) reached the short-flag scan and was wrongly rejected. Both checkers now track value-consuming flags in their separate form and skip the forbidden-flag scan for the immediately-following token. The attached form (`--data=X`) does not consume the next token, so a real flag after it is still scanned. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
8 tasks
noogalabs
pushed a commit
to noogalabs/contextcrawler
that referenced
this pull request
Jun 4, 2026
…hoff#107) Add token-optimized filtering for `cargo nextest` output: strip compilation noise, PASS lines, and post-summary recaps; show only failure details and a compact summary. Extract flush_failure_block helper to DRY up failure block collection (was repeated 4 times). Co-authored-by: Claude Opus 4.6 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the G4 (git + cloud command filters) findings from audit #100 — 2 CRITICAL flag-injection holes. Codex-reviewed across 3 passes; final review: closed, mergeable.
Findings fixed
-K/--configdeny-list bypass. The check now normalises every arg — short-flag char-scan (catches-Kfileattached value,-sKbundling),=-split for long flags, AND prefix-match for abbreviated long options (--conf=fileinvokes--configvia getopt_long prefix-matching).--output-document/-O,--input-file/-i,--load-cookiesentirely — all now in the deny-list, all forms (attached, bundled, abbreviated).scrub_secrets(DSN passwords no longer logged).run_status/run_stash/run_worktreepropagated git's exit code — a non-zero exit was being absorbed into filtered output as apparent success.diff_cmd.rsnormalize_diff_args— ambiguous-tail check before--injection.run_otherkeepsOsStrend-to-end (non-UTF-8 branch names no longer mangled).curl --data -K) or after--is no longer wrongly rejected (value-flag tracking +operands_only).rtk→contextcrawlerin git diff hint + docker/kubectl banners.Review history
3 Codex passes: pass 1 caught the attached-value/bundling bypass; pass 2 caught the abbreviated-long-option bypass + the value-flag false positive; pass 3 verified all closed — every short/long/attached/bundled/abbreviated form of a forbidden flag is rejected, no false positive remains, look-ahead is bounds-safe.
Test plan
cargo test --workspace— 2318 pass, 0 fail;cloud_hardening20 passcargo build --releasecleanPart of the #100 audit.
🤖 Generated with Claude Code