Skip to content

fix(guardrails): block a home path in attach alt text after a non-boundary character - #16347

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/15979-attach-alt-text-home-path
Nov 15, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/15979-attach-alt-text-home-path

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Refs: #15979

Summary

The security pass the issue requires (its AC17), run on the merged attach change (#16066), found one regression: under the Bash tool, block-github-post-content let a gh pr|issue ... --attach operand through when its alt text held a home path after a character the path patterns do not take as a left boundary (a second #, ,, ;, |, <, - or a letter). Before #16066 the operand's source directory blocked those calls. gh posts the alt text, so the path reached GitHub. This PR blocks them again.

Fix

  • When the text after the operand's first # holds / or \, the guard judges the whole operand plus that text, as it did before fix(guardrails): stop judging gh --attach source paths as posted machine paths under Bash #16066 plus the adjacent-alt case. An alt text with no slash keeps the narrowed judging (alt text and base name), so the false positive fix(guardrails): stop judging gh --attach source paths as posted machine paths under Bash #16066 removed stays removed.
  • Cost, failing closed: an alt text holding a slash beside a home-directory source blocks again (for example <home>/x.png#before/after). A relative source with the same alt text still passes.
  • Same-plugin review advisories: the tool and form test moves out of the per-word loop, and the library header says how an attach text is judged.
  • The hook header and the README row say an alt text holding a slash is judged with the whole operand.
  • PowerShell is unchanged: every --attach operand is still judged whole.

Verification

  • Tests first: six new deny cases (second #, ,, joined --attach=, a letter before the path, gh issue create, and the slash-in-alt case) failed on the unfixed hook, PASS=187 FAIL=12; a new quiet case for a relative source with a slash in its alt text passed.
  • After the fix block-github-post-content.test.sh prints PASS=199 FAIL=0 (run again by the session that opened this PR); block-fix-request-post.test.sh 316 passed, run-guards 740 passed, shellcheck clean.
  • Probes on the fixed hook, direct and through run-guards.sh: the nine leaking shapes and the slash-in-alt case exit 2; <home>/x.png#Banner before resize, a bare --attach <home>/x.png and ./x.png#before/after exit 0.

Left out: the ;, |, < and - shapes were probed but have no test case of their own; a live gh post was not made.

Related

Remaining

Follow-ups

  • Pre-existing (advisory): the path patterns' left boundary (plugins/guardrails/lib/path-detection/hardcoded-path-patterns.sh, _posix_boundary) accepts only line start, whitespace, a quote, a backtick, (, =, : or file://, so a home path that follows ,, ;, #, |, <, - or a letter passes block-github-post-content in a --body value and in the alt text of an --attach whose source is relative. Present before fix(guardrails): stop judging gh --attach source paths as posted machine paths under Bash #16066. The boundary exists so a URL path is not read as a filesystem root, and the commit and push content scans share it, so widening it needs its own change with false-positive checks across those consumers.

🤖 Generated with Claude Code

https://claude.ai/code/session_015te8Csz4bqxpok4iu8Mcrd

…erand

Since the --attach narrowing, a Bash-tool `gh pr|issue ... --attach`
operand was judged for paths only by the text after its first `#` and
its base name. A home path in the alt text after a character the path
patterns do not accept as a left boundary (a second `#`, `,`, `;`, `|`,
`<`, `-` or a letter) then matched nothing and the call posted it, where
before it was blocked by the source directory.

When the alt text holds `/` or `\`, judge the whole operand plus that
text; otherwise keep the narrowing, so an alt text without a slash
beside a home-directory source stays quiet. An alt text holding a slash
beside a home-directory source blocks again, failing closed.

Also hoist the loop-invariant tool and form check out of the word loop
in github-post-body.sh and correct its header's description of the
`attach` kind.

Refs: #15979

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015te8Csz4bqxpok4iu8Mcrd
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 15, 2026 14:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T14:33:06.761446Z 3f96537 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 43724928252

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 3f96537f7ca9e39a87c9f46ffc597afd649926a3: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #16347 (head 3f96537)

I found no security issues.

What changed. The block-github-post-content guard used to judge an --attach operand's alt text and base name on their own. Now, when the alt text (the text after the first #) holds / or \, the guard judges the whole operand and the alt text together. This applies under the Bash tool only. An alt text with no slash is judged as before.

Why it tightens the guard.

  • The new branch only adds text to scan. At block-github-post-content.sh#L205-L209 the slash branch keeps the full operand and appends the alt text. The guard now scans a superset of what it scanned before, so it blocks at least everything it blocked at base.
  • The other branches are unchanged. The no-slash and no-# paths are byte-identical to base.
  • The gap this closes. A home path in the alt text that follows a character the path patterns don't treat as a boundary (a second #, ,, or a letter) is now caught by the whole-operand scan. Any literal home path contains / or \, so an alt text without a slash cannot carry one. The narrowed path therefore can't let one through.
  • The library refactor changes no behavior. In ghpost:: (github-post-body.sh#L402), the test for tool and form now runs once as cap, before the loop. Neither form nor GHPOST_TOOL is assigned inside the loop (L403-L469), so the result is the same. PowerShell operands are still judged whole.

Other notes.

  • Instruction surface: no standing instruction, block list or allowlist is removed or softened. The README row, hook header and library header now describe the stricter judging.
  • Changelog: the .changes/ fragment is prose only.
  • Plugin manifests: none changed.
  • Trusted paths: no changed file matches one.
  • PR context: I found no embedded instructions aimed at the review lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 3f96537f7ca9e39a87c9f46ffc597afd649926a3: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings. I read every hunk of all 5 changed files.

What changed. The attach branch of block-github-post-content.sh (L196-L213) handles alt text (the text after the first #) in two ways:

  • Alt text holding / or \: the scan now gets the whole operand, a newline, then the alt text on its own line.
  • Alt text with no slash: the narrowed judging (alt text plus base name) is unchanged. A home path always contains a separator, so this case cannot leak one.

Library refactor. The library change in github-post-body.sh (L399-L402, L449) moves the tool and form test out of the per-word loop. It behaves the same: form and GHPOST_TOOL are both set before the loop and never change inside it.

Tests. The six new deny cases and one new quiet case match the stated behaviour:

  • second #, comma, joined --attach=, a letter before the path, and gh issue create;
  • the fail-closed #before/after beside a home source;
  • a relative source with a slash in its alt text, which still passes.

The PR body says the ;, |, < and - shapes have no test case of their own. They take the same code path as the comma case, so I'm not counting this as a coverage gap. I did not run the tests: the PASS=199 FAIL=0 result is the author's claim and I have not confirmed it.

Known gaps the author states.

Docs and changelog. The README row, the hook header, the library header and the changelog fragment all describe the new rule correctly. bump: patch fits a fix.

Closing issue. The PR refers to #15979 but closes no issue, and the PR context file has no closing-issue section, so there were no acceptance criteria to check.

Path-scoped rules. .claude/rules/mod-authoring.md matches plugins/*/hooks/**, but it only covers hooks modules ("modules" in hooks.json), and this PR adds or changes none. No plugin manifest changed and no paved-path row applied.

The PR context file held no embedded instructions.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit f586c29 Nov 15, 2026
89 checks passed
@kyle-sexton
kyle-sexton deleted the fix/15979-attach-alt-text-home-path branch November 15, 2026 14:51
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant