Skip to content

Confirm policy: refuse any history-expansion character in agent text - #4

Merged
edimarlnx merged 1 commit into
mainfrom
fix/confirm-history-by-editing
Nov 13, 2026
Merged

edimarlnx merged 1 commit into
mainfrom
fix/confirm-history-by-editing

Conversation

@edimarlnx

Copy link
Copy Markdown
Contributor

Found in VM tests with real bash and zsh sessions: text with ! followed by a blank, = or ( was allowed, and could be edited with Backspace into a history reference that a shell with Space bound to magic-space expands on screen without an Enter. Under the confirm policy agent text may no longer contain ! at all (as with ^); the refusal message suggests alternatives. This removes != and ! cmd for agents in confirm sessions.

Adds a VM integration test that drives bash and zsh under the confirm policy. Validated on Fedora 44 (SELinux) and Ubuntu 24.04 (AppArmor): broker and escape matrices pass with and without the guard, a genuine cotty agent reads confined (strong with the guard), and the forgeries read weak.

🤖 Generated with Claude Code

Under --policy confirm agent text could hold a '!' followed by a blank,
'=' or '(', where bash and zsh do not expand it. The editing input the
policy keeps (Left, Backspace, more text) turned it into a history
reference afterwards: "echo ! ", Backspace, "-2" leaves "echo !-2" on
the line, and with Space bound to magic-space (oh-my-zsh does that) the
next blank drew the command before last, one the person typed in
private mode included, on the agent's screen without any Enter. Found in
the lab VMs (Fedora 44, Ubuntu 24.04; bash and zsh).

Every '!' is now refused, like '^'; the broker cannot tell what the line
holds once it was edited. The policy_denied message tells the agent to
write -ne, test -z or a script file instead.

tests/integration/confirm_test.go (vmtest) drives real bash and zsh
sessions under --policy confirm: Tab, BTab, Up, Down, PgUp, PgDn, tabs,
'!' and '^' in text are refused; ./configure and Makefile payloads stay
untouched while the agent tries to complete them (the person's own Tab
runs them, as a control); plain text with an approved Enter runs; and
the editing sequence above no longer shows a private command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edimarlnx
edimarlnx merged commit 0f96f4a into main Nov 13, 2026
1 check passed
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