Skip to content

fix(ci): mitigate template injection in GitHub Actions workflows#351

Merged
rolginroman merged 1 commit into
masterfrom
fix/template-injection-ci
Apr 27, 2026
Merged

fix(ci): mitigate template injection in GitHub Actions workflows#351
rolginroman merged 1 commit into
masterfrom
fix/template-injection-ci

Conversation

@rolginroman
Copy link
Copy Markdown
Contributor

Summary

Fixes template injection vulnerabilities in GitHub Actions workflows identified by Aikido security scan.

GitHub Actions run: blocks that directly embed ${{ }} template expressions referencing untrusted inputs (branch names, PR numbers, workflow dispatch params) are vulnerable to script injection. An attacker can craft a malicious branch name or PR body containing shell metacharacters that get evaluated by bash when the workflow runs.

Vulnerabilities Fixed

.github/workflows/gh-alpha-release.yml (6 injection points):

  • ${{ github.event_name }} — used in if comparisons in shell
  • ${{ github.head_ref }} — attacker-controlled branch name injected directly
  • ${{ github.event.pull_request.number }} — injected into shell variable
  • ${{ github.event.inputs.pr_number }} — user-supplied workflow dispatch input
  • ${{ needs.resolve-alpha.outputs.alpha_version }} — injected into pnpm version-all arg and git commit -m

.github/workflows/gh-publish.yml (1 injection point):

  • ${{ github.repository }} — injected into github-script template literal

Fix

All ${{ }} expressions inside run: and script: blocks are moved to env: mappings, then referenced as shell environment variables ($VAR). Environment variable assignment treats values as literal strings, preventing shell metacharacter evaluation.

Test plan

  • Verify YAML syntax is valid (confirmed via ruby -ryaml)
  • Confirm no ${{ }} expressions remain in any run: blocks across both files
  • Trigger the alpha release workflow on a branch prefixed alpha/* and verify it resolves the version correctly
  • Merge a PR to master and verify the publish workflow creates the release and comment as expected

Move all ${{ github.* }} and ${{ needs.* }} expressions out of run: blocks into env: variables to prevent script injection via untrusted inputs (branch names, PR numbers, workflow dispatch params).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@rolginroman rolginroman requested a review from Yolley April 24, 2026 10:29
@rolginroman rolginroman merged commit b18d604 into master Apr 27, 2026
8 checks passed
@rolginroman rolginroman deleted the fix/template-injection-ci branch April 27, 2026 15:59
@github-actions
Copy link
Copy Markdown

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