Skip to content

fix(guard): catch rm -rf / and crontab - where they end inside JSON - #151

Merged
fylorn merged 1 commit into
mainfrom
fix/rm-rf-in-json
Sep 23, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/rm-rf-in-json

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

The wall matches a tool call's arguments as JSON text, where a command ends at a closing quote: {"command":"rm -rf /"}. rm-rf-root and crontab-install anchored the end of the command on whitespace or end of input, so the most common form of both calls went unseen. This affected the desktop too. A new server-edition unit test caught it.

Both rules now also accept a quote, ;, &, | or ) after the command.

A new test covers the JSON forms:

  • These now match: rm -rf /, rm -rf ~, rm -rf $HOME && …, rm -rf /;ls, … | crontab -.
  • These still don't: rm -rf /tmp/build, rm -rf ~/project/node_modules, crontab -l.

cargo test --workspace and clippy pass.

🤖 Generated with Claude Code

The wall matches a tool call's arguments as JSON text. A command there
ends at a closing quote, `{"command":"rm -rf /"}`, but rm-rf-root and
crontab-install anchored the end of the command on whitespace or end
of input, so the most common form of both calls went unseen — on the
desktop as well as in the server edition, where a new test caught it.

Both now also accept a quote, `;`, `&`, `|` or `)` after the command.
A path under home or root (`rm -rf /tmp/build`) and `crontab -l` still
do not match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 00ac476 into main Sep 23, 2026
2 checks passed
@fylorn
fylorn deleted the fix/rm-rf-in-json branch September 23, 2026 20:16
@fylorn fylorn mentioned this pull request Sep 23, 2026
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