Skip to content

fix(skills): inert report text and quoted search/message data are words, not a run (#827) - #855

Draft
hr1juldey wants to merge 1 commit into
trailhq:mainfrom
hr1juldey:fix/827-agentguard-quoted-text
Draft

hr1juldey wants to merge 1 commit into
trailhq:mainfrom
hr1juldey:fix/827-agentguard-quoted-text

Conversation

@hr1juldey

Copy link
Copy Markdown

Fixes #827.

Root cause

textProgram — the default "quiet" for the switch finder in quotedTextHit — rejected anything outside its TEXT_PROGRAMS list, so a gh --search string, a paseo message argument, and a python stdin script writing the words as a string literal all read as runs.

Fix (narrow, per the issue's own caution about broadening)

  • gh joins the word-programs behind an enumerated GH_WORDS list; the remote-session and extension-running verbs (codespace, extension) stay guarded. paseo joins like echo/printf.
  • python stdin scripts (python3 - <<'PY') are inert only when the script runs nothing itself — PY_RUNS catches os/subprocess escapes, eval/exec, dynamic imports, pty drivers, and the getattr/compile/globals indirection that could smuggle one — and the words sit only inside quoted literals. Python only; any other interpreter stays guarded.

Tests (adversarial set)

Inert: the issue's four cases, plus dynamic assembly ('trail ' + 'skills on', f-strings). Still denied: os.system, subprocess.run(shell=True), getattr(os, 'system'), exec, a script FILE argument, a node heredoc, echo | python3, gh extension run, gh codespace ssh, real activation.

Pre-existing hole found, not fixed here

While writing the adversarial set: an unquoted heredoc delimiter with $(…) in the body (python3 - <<PY + print('$(trail skills on)')) is a real shell run the scan layer never attributes — quotedTextHit skips substitution-capable heredoc bodies, pre-existing on main. Left out deliberately (touches segment pairing in the core scanner); happy to take it in a follow-up if you want it.

…ds, not a run

agentGuard denied inert commands because textProgram — the default
quiet for the switch finder — knew nothing beyond its TEXT_PROGRAMS
list:

- 'gh issue list --search' and 'paseo send' quoted arguments read as
  runs. gh joins the word-programs behind an enumerated safe-verb list
  (GH_WORDS) — the remote-session and extension-running verbs
  (codespace, extension) stay guarded; paseo joins like echo.
- a python stdin script writing the words as a string literal
  (python3 - <<'PY' … write_text('skills on')) read as a run. The new
  stdin branch is inert only when the script runs nothing itself
  (PY_RUNS: os/subprocess escapes, eval/exec, dynamic imports, pty
  drivers, and the getattr/compile/globals indirection that could
  smuggle one) and the words sit only inside quoted literals. Python
  only — any other interpreter, a script FILE argument, and an
  unquoted heredoc delimiter stay guarded.

Real activation, os.system, subprocess, exec with the words in the
clear, getattr indirection, node heredocs, and echo | python3 all stay
denied. Found while writing the adversarial set, reported not fixed
here: an UNQUOTED heredoc delimiter with a $(…) in the body is a real
shell run the scan layer never attributes — pre-existing on main,
touches quotedTextHit's segment pairing, left for a separate fix.
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

Nothing outside this diff depends on it. 1 area changed; no indexed dependents at depth 2.
Tests: no test reaches Shell Word Parsing.
Tag: @shhdwi — Shell Word Parsing

Who knows this code — 1 person across 1 area
Area Who knows it
Shell Word Parsing · changed @shhdwi — 1 commit, last 28d ago

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

Test signal per changed area — 1 ✗

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • ✗ Shell Word Parsing — 0 of 1 reached · no test file reaches it
    • not reached: textProgram

graft blast · origin/main...HEAD · depth 2 · 2 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

This branch has not been deployed

No deployments
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.

PreToolUse agentGuard blocks inert report text and quoted search/message arguments

1 participant