Skip to content

Commit 5e047ab

Browse files
thebiglabaskyclaude
andcommitted
fix(ci): prevent shell injection in claude-code workflow
Move github.event.issue.body/title/number and comment.body from inline ${{ }} expansion in the run: script to the step's env: block. GitHub Actions substitutes template expressions into the shell script as literal text before bash runs, so attacker-controlled issue content could escape the quoted string and execute arbitrary commands. Reading the values from the process environment via $ISSUE_BODY etc. avoids re-parsing and closes the injection vector. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7aa4442 commit 5e047ab

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.github/workflows/claude-code.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ jobs:
2525
env:
2626
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
2727
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
# Pass attacker-controlled fields via env to avoid shell injection.
29+
# GitHub Actions template expansion (${{ ... }}) is substituted into
30+
# the run script verbatim, so interpolating issue/comment content
31+
# directly would allow command injection. Env vars are expanded by
32+
# bash at runtime and are not re-parsed.
33+
ISSUE_BODY: ${{ github.event.issue.body || github.event.comment.body }}
34+
ISSUE_NUMBER: ${{ github.event.issue.number }}
35+
ISSUE_TITLE: ${{ github.event.issue.title }}
2836
run: |
2937
# Install Claude Code
3038
curl -fsSL https://claude.ai/install.sh | bash
31-
32-
# Get issue content
33-
ISSUE_BODY="${{ github.event.issue.body || github.event.comment.body }}"
34-
ISSUE_NUMBER="${{ github.event.issue.number }}"
35-
ISSUE_TITLE="${{ github.event.issue.title }}"
36-
39+
3740
# Create branch name
3841
BRANCH_NAME="claude/issue-${ISSUE_NUMBER}"
3942

0 commit comments

Comments
 (0)