Skip to content

approval: a recursive delete asks in any spelling, and a no covers the act (#2813) - #2852

Open
7vignesh wants to merge 5 commits into
Agent-Field:devfrom
7vignesh:fix/2813-critical-rm-spellings
Open

7vignesh wants to merge 5 commits into
Agent-Field:devfrom
7vignesh:fix/2813-critical-rm-spellings

Conversation

@7vignesh

Copy link
Copy Markdown
Contributor

Closes #2813.

What was wrong

A model whose rm -rf /tmp/victim was refused ran rm -r /tmp/victim one call later, and it ran without asking. Every rm entry in the critical-command table spells rm -rf / or rm -fr /, so only that exact text was caught. The issue's probe, run on dev c4ce12c6a, graded only rm -rf /tmp/victim as critical.

What changed

internal/approval/bash.go: criticalHit checks for a recursive delete before it consults the text table. The new recursiveRemoveHit reads the command through the package's existing CommandWords and unwrap, so quotes, sudo/env/timeout and /bin/rm are handled the way the credential floor already handles them. An rm with -r, -R or --recursive (clustered, split, with or without -f, or after --) aimed at an absolute path, ~, $HOME/${HOME} or a bare * is critical. Two rule names are reported, both of them spellings a person can find in the manual: rm -rf /* for a path, rm -rf * for a bare *.

Unchanged: relative targets (rm -rf build, rm -r ./build, rm -rf build/*), single-file deletes (rm /tmp/one.log), git rm -r, grep -r and echo 'rm -r …' all still run under an allow without asking. find -delete and the rest of the unbounded list stay out of scope, as the issue says.

internal/session/consent.go: a person's no now continues … They said no to this action, not to this spelling: ask before doing the same thing another way. It still starts with denied by the person: <rule>, so every reader of that prefix (the factory receipts, the existing tests) is unaffected. Only the model reads it; the person's transcript row still says denied.

internal/manual/chat/permissions.md: names the spellings that ask and quotes the new sentence. The page already promised that rm -rf * asks, but no table entry matched it; now it does.

Tests

  • TestCriticalHit gains the issue's whole list as true rows, plus sudo, compound-line, single-quoted, braced ${HOME}, ~/… and second-target cases. The false rows the issue says must stay (rm -rf build, rm -rf ./tmp/x, rm -r ./build) are kept, along with new false rows for single files, rm -- -r, echo rm … and rmdir.
  • TestEveryCriticalCommandTheManualNamesIsAskedAbout reads the manual's a critical command (…) sentence and fails if the gate doesn't ask about one of the commands in it. It fails on rm -rf * without this change and passes with it.

How it was checked

On native Windows 11:

  • go build ./..., go vet and gofmt pass.
  • TestCriticalHit (49 cases), the new manual law, TestCheckCriticalCommands and the TestAlwaysAsks* floor tests pass.
  • TestTheChatManualAnswersTheQuestionsPeopleAsk and TestExecutionNotesReceiptOutcomes pass.
  • The consent and !-command tests that read the denial wording pass when run one at a time.

These fail identically on unchanged dev on Windows, so they aren't caused by this change:

  • four internal/approval credential tests (Windows paths)
  • the allow subtest of TestUserBashCriticalFloorAsksUnderAllow
  • TestARefusedPermissionIsNeverKeptAsARuleAndTheNextTurnStillNotices, which hangs
  • two internal/manual checks that trip on CRLF line endings

CI's touched packages is the proof on Linux.

e2e not run: no key, and no tmux. The issue's tmux acceptance (a deny of rm -rf <dir>, then a second card for rm -r <dir> with the folder still there) is not covered here.

7vignesh and others added 5 commits November 20, 2026 01:17
…e act (Agent-Field#2813)

A model refused `rm -rf /tmp/victim` ran `rm -r /tmp/victim` one call
later and was never asked, because every rm entry in the critical table
spells `rm -rf /`. criticalHit now reads the delete through CommandWords
and unwrap: -r, -R, --recursive in any clustering, with or without -f,
after sudo/env/timeout or as /bin/rm, quoted, or after --, aimed at an
absolute path, ~, $HOME or a bare *. Relative targets stay ungraded.

The person's no now tells the model it covered the action, not the
spelling. permissions.md names the spellings, and a law test fails the
build if the manual lists a critical command the gate does not ask about
(rm -rf * was promised and never matched).
… its rule (Agent-Field#2813)

TestTheMemoDoesNotAnswerForACriticalCommand pins `rm -rf /` to the rule
`critical command "rm -rf /"`. Checking the recursive delete before the
table reported it as "rm -rf /*" instead. The table now answers first, and
only what it misses is read as a recursive delete.
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.

After the person denies a critical command, the model can run the same delete as rm -r and it runs without asking

1 participant