Skip to content

fix: harden shell interpolation in action workflows#74

Merged
bolinfest merged 1 commit intomainfrom
pr74
Mar 16, 2026
Merged

fix: harden shell interpolation in action workflows#74
bolinfest merged 1 commit intomainfrom
pr74

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Mar 16, 2026

Why

A user pointed out that the README pull request example interpolated ${{ github.event.pull_request.base.ref }} directly into a shell command. GitHub Actions expands ${{ ... }} expressions before the shell runs, so copying that pattern into a workflow can let attacker-controlled values such as branch names break shell syntax and execute arbitrary commands.

This change hardens both the published examples and the composite action itself so we are not shipping that pattern to users.

What changed

  • updated the README pull request review example to pass PR metadata through env: and consume it as quoted shell variables
  • added guidance to docs/security.md explaining why direct ${{ ... }} interpolation inside run: blocks is unsafe
  • hardened action.yml so action inputs and step outputs are passed into shell steps through environment variables instead of being spliced directly into commands
  • updated examples/test-sandbox-protections.yml to use the same safe pattern

Verification

  • re-scanned this repository for attacker-controlled GitHub expressions or action inputs interpolated directly into run: blocks
  • parsed action.yml and examples/test-sandbox-protections.yml with Ruby YAML.load_file to confirm the edited workflow files still parse
@bolinfest bolinfest changed the title fix: harden GitHub Actions shell interpolation Mar 16, 2026
@bolinfest bolinfest requested review from Zemnmez and pakrym-oai March 16, 2026 23:09
@bolinfest bolinfest merged commit 39b4832 into main Mar 16, 2026
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants