Skip to content

fix(ci): Prevent script injection in ai-pr-review workflow - #10

Merged
zhongkechen merged 1 commit into
mainfrom
fix/script-injection-ai-pr-review
Aug 4, 2026
Merged

fix(ci): Prevent script injection in ai-pr-review workflow#10
zhongkechen merged 1 commit into
mainfrom
fix/script-injection-ai-pr-review

Conversation

@ayushiahjolia

Copy link
Copy Markdown
Contributor

Issue #, if available: N/A

Description of changes:
Mitigate potential script injection in the ai-pr-review.yml workflow by assigning github.event.pull_request.head.sha to an environment variable instead of interpolating it directly in a run: block.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ayushiahjolia
ayushiahjolia marked this pull request as ready for review August 4, 2026 21:49
@ayushiahjolia
ayushiahjolia temporarily deployed to ai-pr-review-runtime August 4, 2026 21:49 — with GitHub Actions Inactive
@ayushiahjolia
ayushiahjolia temporarily deployed to ai-pr-review-runtime August 4, 2026 21:49 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codex AI review

No actionable findings. Residual risk is limited to the workflow change not being runtime-tested in this review.

Reviewed commit 4c6579f92a99a543def7e37ad57049beab25c467. Workflow run

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Claude AI review

This PR mitigates a potential script-injection vector in .github/workflows/ai-pr-review.yml by moving github.event.pull_request.head.sha from direct ${{ }} interpolation inside the run: shell into an env: variable (HEAD_SHA) and referencing it as $HEAD_SHA. This is the correct, recommended GitHub Actions pattern: the shell no longer evaluates untrusted expression-substituted text. The variable name is consistent between env: and the run: step, the value is properly quoted, and the echoed message semantics are unchanged. No correctness, typing, error-handling, or lifecycle issues were found. Residual test risk: GitHub Actions workflows are not unit-tested in this repo, so this defensive, no-functional-change hardening relies on review rather than automated verification; risk is minimal.

Reviewed commit 4c6579f92a99a543def7e37ad57049beab25c467. Workflow run

- name: Record approval
run: echo "Approved review of ${{ github.event.pull_request.head.sha }}"
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is sha field injectable?

@zhongkechen
zhongkechen merged commit 92d2ff3 into main Aug 4, 2026
20 of 21 checks passed
@zhongkechen
zhongkechen deleted the fix/script-injection-ai-pr-review branch August 4, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants