Skip to content

Commit ab6bdd9

Browse files
bloveclaude
andcommitted
fix(ci): prevent shell injection via github.head_ref in api-docs push
Bind github.head_ref to an env var (HEAD_REF) and reference "$HEAD_REF" instead of interpolating the PR branch name into the run: script. Resolves OSSF Scorecard Dangerous-Workflow finding (ci.yml:119). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e973a11 commit ab6bdd9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ jobs:
116116
- run: npm run generate-api-docs
117117
- name: Commit generated API docs to same-repo PR
118118
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
119+
env:
120+
# Bind the attacker-controllable PR branch name to an env var so it is
121+
# passed as a literal value, never interpolated into the script text
122+
# (prevents shell injection — OSSF Scorecard Dangerous-Workflow).
123+
HEAD_REF: ${{ github.head_ref }}
119124
run: |
120125
if git diff --quiet -- apps/website/content/docs/*/api/api-docs.json; then
121126
echo "Generated API docs are already committed."
@@ -126,7 +131,7 @@ jobs:
126131
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
127132
git add apps/website/content/docs/*/api/api-docs.json
128133
git commit -m "chore(docs): regenerate api docs"
129-
git push origin "HEAD:${{ github.head_ref }}"
134+
git push origin "HEAD:$HEAD_REF"
130135
- name: Verify generated API docs are committed
131136
run: git diff --exit-code -- apps/website/content/docs/*/api/api-docs.json
132137
- run: npx nx build website

0 commit comments

Comments
 (0)