Repository navigation
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
Open
karakos-amos[bot] wants to merge 1 commit into
karakos-amos[bot] wants to merge 1 commit into
Conversation
…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
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.
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:
head -0/tail -n 0. The pipeline's status becomes head's, so the check leaves no result at all.systemctl showwith no-p, or with-p Environment, and no grep/rg/sed/awk stage after it. It prints everyEnvironment=value, secrets included.catwith no file, heredoc, here-string,<redirect or pipe feeding it. It reads the tool's stdin until the time limit. Acatafterdo/then/{or inside$(...)passes, since an outer redirect may feed it.lib/bashcmd.pygainsstages(): the same commands ascommands(), asStagelists that also carrystdin,upstream,downstream,nestedandkeyword. A trailing|before a newline keeps its link.commands()is unchanged;evaluate()now iteratesstages().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.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