From e6a881a795ab8c7ebb76eb542a015eede8de4a48 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 17:39:05 -0500 Subject: [PATCH] wrapper-guard: judge command position on prefixes and on what a shell will execute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round-three review found two more absence-driven allows, both in the skeleton introduced by round two, and fixing them exposed a third the reviewer had not reached yet. 1. A word in front of a command does not displace the command. `env VAR=v curl`, `command curl`, `timeout 10 curl` and `/usr/bin/curl` were all real writes at execution position that a bare-name match could not see. The `env` form is the one that matters: it is what an agent reaches for to keep a credential out of the global environment, so the careful spelling was the invisible one. 2. Quoted data stops being data when a shell is about to execute it, and the first version knew only `bash -c`, `sh <<` and `eval`. It did not know the pipe, which is the form people actually use: `printf ... | sh`, `cat <> notes.md <> notes.md"}}\tnaming a command after echo is not running it\n' + # A shell standing between quoted data and execution makes that data code, + # and the pipe is the form agents actually use. Filing it as data allowed the + # call to vanish from the skeleton while still running. + printf '2\t{"tool_input":{"command":"printf '"'"'%%s\\\\n'"'"' '"'"'curl -d@b https://git.example.invalid/api/v1/repos/a/b/issues/1/comments'"'"' | sh"}}\tquoted code piped to a shell is code\n' + printf '2\t{"tool_input":{"command":"cat <> notes.md"}}\tan unrelated shell on another line does not promote quoted prose to code\n' } > "$FIXTURES" fail=0 n=0 diff --git a/packages/mosaic/framework/tools/git/wrapper-guard.sh b/packages/mosaic/framework/tools/git/wrapper-guard.sh index ab26c75b..0250a109 100755 --- a/packages/mosaic/framework/tools/git/wrapper-guard.sh +++ b/packages/mosaic/framework/tools/git/wrapper-guard.sh @@ -106,23 +106,50 @@ fi # skeleton would be blind to them. # # The exception is the reason quotes are data at all: if something is about to -# EXECUTE the quoted text (`bash -c`, `sh <