Repository navigation
fix(system): grep -- argument boundary; tree/find path fixes (#111 G5) - #112
Merged
Merged
Conversation
…fixes (#111 G5) grep_cmd.rs (CRITICAL): the rg/grep argv placed pattern and path with no `--` separator, so a pattern shaped like `--pre=<cmd>` reached rg unscanned and ran an arbitrary preprocessor (RCE, #32). Restructure both the rg path and the plain-grep fallback as: fixed flags, then forbidden-checked extra_args, then `--`, then pattern, then path. Mirrors the #100 G5#1/#2 boundary already in ls.rs/tree.rs. tree.rs: confirmed `-o filename` is genuine native tree (v2.x) output-file flag — kept in VALUE_FLAGS with a clarifying comment; extracted the flag/path splitter into a testable helper. find_cmd.rs: a trailing slash on the search root made strip_prefix fail and emit absolute paths, breaking the relative-path contract. Normalise the walk root (strip trailing slash) before walking and stripping. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closed
8 tasks done
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 G5 findings from the independent Claude review (#111). Codex-reviewed: mergeable.
Findings fixed
grep_cmd.rshad no--argument boundary — a--pre=<cmd>-shaped pattern reached rg as a flag, unscanned (check_forbidden_rg_argsonly scansextra_args). rg--preruns an arbitrary preprocessor command (RCE). Thels/treesiblings got the--boundary in #100; grep was missed. Now the rg argv is fixed flags → optional--type→ forbidden-checkedextra_args→"--"→ pattern → path. The plain-grepfallback got the identical treatment.tree -overified a real option (-o file= output to file) — kept inVALUE_FLAGS, splitter extracted tosplit_flags_and_paths()for testability.find_cmd.rs—walk_rootstrips a trailing slash sostrip_prefixreliably yields relative paths instead of falling back to absolute.Test plan
cargo test --workspace— 2347 lib tests pass, 0 fail;system_hardening4/4--pre=-shaped pattern never executes (marker-file PoC),--leading path searched correctly, tree splitter, find trailing-slashcargo build --releasecleanPart of the #111 audit.
🤖 Generated with Claude Code