Skip to content

bash-safety-rails: deny a check piped into head -0, systemctl show Environment and a bare cat - #369

Open
karakos-amos[bot] wants to merge 1 commit into
developfrom
feat/bash-rails-pipe-stages
Open

karakos-amos[bot] wants to merge 1 commit into
developfrom
feat/bash-rails-pipe-stages

Conversation

@karakos-amos

@karakos-amos karakos-amos Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Part 3b of the guard-layer forward-port (taskboard d7d77714). Three more Bash rails, matched against parsed commands only, so prose, rg patterns and heredoc bodies never trip them:

  • zero-output-sink: a check (tsc, vitest, jest, pytest, eslint, mypy, ruff, npm/pnpm/yarn test, cargo test ...) piped into head -0 / tail -n 0. The pipeline's status becomes head's, so the check leaves no result at all.
  • systemctl-show-env: systemctl show with no -p, or with -p Environment, and no grep/rg/sed/awk stage after it. It prints every Environment= value, secrets included.
  • bare-cat: a top-level cat with no file, heredoc, here-string, < redirect or pipe feeding it. It reads the tool's stdin until the time limit. A cat after do/then/{ or inside $(...) passes, since an outer redirect may feed it.

lib/bashcmd.py gains stages(): the same commands as commands(), as Stage lists that also carry stdin, upstream, downstream, nested and keyword. A trailing | before a newline keeps its link. commands() is unchanged; evaluate() now iterates stages().

Not in this PR (part 3c): secrets dump, session cookie, PIN, pgrep -f loop, prose in argv, /tmp body files, and ssh-payload recursion for systemctl show.

Tests

  • tests/test_bash_rails.py + tests/test_docs.py: 202 passed. Of the new tests, 16 fail without the change.
  • Hook-related suites (test_bash_rails, test_verify_public_safety, test_docs, *hook*/*rail*): 234 passed, 1 failed, test_hooks_wiring.py::test_real_claude_dispatch_fires_user_prompt_submit_hook, which also fails on unmodified develop on this host.
  • system/check-coupling.sh: clean.

🤖 Generated with Claude Code

…vironment and a bare cat

Three more rails forward-ported from the household guard layer, written
against parsed commands so prose, rg patterns and heredoc bodies never match:

- zero-output-sink: tsc, vitest, pytest, eslint, npm test and similar piped
  into head -0 / tail -n 0, which discards the result and its exit status
- systemctl-show-env: systemctl show with no -p, or -p Environment, unless a
  grep/rg/sed/awk stage follows (prints every Environment= secret)
- bare-cat: a top-level cat with no file, heredoc, here-string, < or pipe
  feeding it (reads the tool's stdin until the time limit); a cat inside
  do/then/{ or a $(...) passes, since an outer redirect may feed it

lib/bashcmd.py gains stages(): the same commands as commands(), as Stage
lists that also carry stdin (own < / << / <<< redirect), upstream and
downstream (pipe neighbours), nested and keyword. commands() is unchanged;
evaluate() now iterates stages().

Not ported here (taskboard d7d77714 PR 3c): secrets dump, session cookie,
PIN, pgrep -f loop, prose in argv, /tmp body files, and the ssh payload
recursion for systemctl show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant