Skip to content

Commit 567d6c5

Browse files
samkimclaude
andcommitted
Fix code injection via github.head_ref in shell context
With pull_request_target, github.head_ref is controlled by the fork author. Passing it through an environment variable instead of inline expression syntax prevents shell injection via crafted branch names. Resolves code scanning alert #8. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9a8ce6f commit 567d6c5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

.github/workflows/vercel-preview.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ jobs:
125125
VERCEL_TOKEN: "${{ secrets.VERCEL_TOKEN }}"
126126
VERCEL_ORG_ID: "${{ secrets.VERCEL_ORG_ID }}"
127127
VERCEL_PROJECT_ID: "${{ secrets.VERCEL_PROJECT_ID }}"
128+
HEAD_REF: "${{ github.head_ref }}"
128129
run: |
129130
npm install --global vercel@latest
130131
@@ -133,7 +134,7 @@ jobs:
133134
134135
# Sanitize branch name for DNS: lowercase, non-alphanumeric to hyphens, collapse runs
135136
# Truncate to 46 chars so the full alias (docs-git-<branch>-authzed) stays within the 63-char DNS label limit
136-
BRANCH=$(echo "${{ github.head_ref }}" \
137+
BRANCH=$(echo "$HEAD_REF" \
137138
| tr '[:upper:]' '[:lower:]' \
138139
| sed 's/[^a-z0-9]/-/g' \
139140
| sed 's/-\+/-/g' \

0 commit comments

Comments
 (0)