Skip to content

ci: prevent shell injection in status-check workflow - #39

Open
olaservo wants to merge 3 commits into
mainfrom
feature/security-hardening
Open

ci: prevent shell injection in status-check workflow#39
olaservo wants to merge 3 commits into
mainfrom
feature/security-hardening

Conversation

@olaservo

Copy link
Copy Markdown
Member

Summary

Fixes the open critical code scanning alert (actions/code-injection/critical) in .github/workflows/status-check.yml.

The "Get PR number" step interpolated ${{ github.event.workflow_run.head_branch }} directly into a run: shell script. A PR author controls their own branch name, so a branch named rce$(...) executes arbitrary commands on the runner — which holds a GITHUB_TOKEN with statuses: write and checks: write. This is a live target: PR #32's branch name is a working injection payload against this exact line.

Fix

Move the branch name (and the other two templated values in the step) into env: and reference them as quoted shell variables. GitHub Actions template expansion no longer touches the script body, so attacker-controlled input can't break out of the string.

No behavior change for legitimate runs.

Not addressed here

The other open alert — critical vitest advisory (Dependabot #4) — is already covered by open PR #14, so it's intentionally left out of this PR.

🤖 Generated with Claude Code

The "Get PR number" step interpolated github.event.workflow_run.head_branch
directly into a run: script. A PR author controls their branch name, so a
name like rce$(...) executes arbitrary commands on the runner, which has a
GITHUB_TOKEN with statuses:write and checks:write.

Pass the branch name, event name, and PR number through env: and reference
them as quoted shell variables so untrusted input is never templated into the
script body.

Fixes code scanning alert #1 (actions/code-injection/critical).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 19, 2026 01:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Secures the status-check workflow against branch-name shell injection.

Changes:

  • Passes GitHub event values through environment variables.
  • Uses quoted shell expansions for attacker-controlled branch names.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/status-check.yml Outdated
The step's number output was never read by any other step. The
Check required statuses step derives its ref from head.sha / head_sha
in the event payload, not from a PR number.

Removing the step also removes the shell-injection sink outright
(gh pr list --head with an attacker-controlled branch name) instead
of only quoting around it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 19, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/status-check.yml:28

  • The implementation removes the entire PR-number step rather than moving its expressions into env: as the PR's Fix section states. Since the removed output is unused, deletion still addresses the injection, but the PR description should be updated to document the actual remediation and avoid a misleading security audit trail.
      - name: Get changed files

Copilot AI review requested due to automatic review settings August 19, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

3 participants