Skip to content

Conversation

@mediremi
Copy link
Member

In GitHub Actions workflows, using template expansions (${{ ... }}) in run (and other code execution) blocks can lead to template injection vulnerabilities.

From the link above:

These expansions happen before workflow and job execution, meaning the expansion of a given expression appears verbatim in whatever context it was performed in.

Template expansions aren't syntax-aware, meaning that they can result in unintended shell injection vectors. This is especially true when they're used with attacker-controllable expression contexts

zizmor identified two locations in .github/workflows/ci.yml where code injection via template expansion may be possible:

  1. -B ${{ github.ref }} \
  2. git commit -m "Update API docs for ${{ github.ref_name }}"

As recommended by GitHub's Security Lab, I've replaced these template expansions with environmental variables.

The $GITHUB_REF and $GITHUB_REF_NAME environmental variables are already defined by default, so we don't need to define them with env:.

gh actions-cache delete ${{ steps.compiler-build-state-key.outputs.value }} \
-R ${{ github.repository }} \
-B ${{ github.ref }} \
-B "$GITHUB_REF" \
Copy link
Member Author

Choose a reason for hiding this comment

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

I've wrapped this env var with quotes to avoid word splitting

@mediremi mediremi requested a review from cknitt October 22, 2025 16:46
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 22, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7982

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7982

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7982

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7982

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7982

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7982

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7982

commit: 15806f7

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Thanks @mediremi! 👍

@mediremi mediremi merged commit 737c1b4 into rescript-lang:master Oct 22, 2025
25 checks passed
@mediremi mediremi deleted the mitigate-workflow-template-injection branch October 22, 2025 18:10
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