Repository navigation
fix(safety): deny file-writing and exec flags in default-allowed tools - #2
Conversation
Extends the hard denylist beyond find's -exec family (#1): - find: -fprint, -fprint0, -fprintf, -fls write arbitrary files anywhere on disk; cwd containment only covers the working directory. - rg --pre CMD runs CMD for every searched file. - git diff/log/show --output=PATH writes to PATH. - tree -o / --output writes to PATH (including bundled -ao). Program-specific flags are matched against the basename of the first token so they don't collide with unrelated uses (grep -o, rg --pretty). Also applies rustfmt to the tests added in #1 so `cargo fmt --check` passes on main again.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6253c9b6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// an exact token or as the `flag=value` form. | ||
| const PROGRAM_DENY: &[(&str, &str)] = &[ | ||
| // `rg --pre CMD` runs CMD once per searched file: arbitrary execution. | ||
| ("rg", "--pre"), |
There was a problem hiding this comment.
Deny ripgrep's hostname executable flag
When the launch tree contains an executable script, the default rg ** rule still permits arbitrary execution through a matching search such as rg --hostname-bin ./payload --hyperlink-format 'file://{host}{path}' --color always PATTERN .. Ripgrep 15.1.0's --help explicitly documents that --hostname-bin=COMMAND runs the supplied executable, and this check only denies --pre, so the new protection leaves another default-allowed execution path open; add --hostname-bin to the program-specific deny entries.
Useful? React with 👍 / 👎.
Follow-up to #1. The default read-only allowlist still let a few commands write files or run programs:
find -fprint/-fprint0/-fprintf/-flscreate or truncate arbitrary paths. Working-directory containment only covers the cwd, not arguments.rg --pre CMDruns CMD once per searched file.git diff/log/show --output=PATHwrites to PATH.tree -o PATH/--outputwrites to PATH, including bundled short flags like-ao.The find flags join the existing hard denylist. The others are scoped to their program (matched on the basename of the first token), so
grep -o,rg --pretty, and similar stay allowed.This also runs rustfmt over the tests from #1, which currently fail
cargo fmt --check.Tested:
safety.rscompiles, passes clippy with-D warnings, and all 12 unit tests pass (standalone build with thiserror and shlex). CI here covers the full crate.