Fix script injection in release.yml via env-var indirection#7
Open
felicityzhao9 wants to merge 1 commit into
Open
Fix script injection in release.yml via env-var indirection#7felicityzhao9 wants to merge 1 commit into
felicityzhao9 wants to merge 1 commit into
Conversation
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.
Summary
Fixes a script-injection vulnerability (CWE-94) in
.github/workflows/release.yml.Untrusted
workflow_dispatchinputs (version_number,commit_id) andgithub.actorwere interpolated directly into shell
run:blocks, allowing arbitrary commandexecution if a crafted value were supplied when dispatching the release workflow.
What changed
Applied environment-variable indirection — the same pattern already used safely
by the
clean-existing-tag-and-releasejob — to the two affected jobs:add-sbom-and-tag-commit: added a job-levelenv:block(
VERSION_NUMBER,COMMIT_ID,ACTOR) and replaced every${{ github.event.inputs.* }}/${{ github.actor }}reference insiderun:blocks with quoted shell variables (
"$VERSION_NUMBER","$COMMIT_ID","$ACTOR").create-zip: added a job-levelenv:block and replaced the${{ github.event.inputs.version_number }}references in thezip/unzip/diffrun:steps with"$VERSION_NUMBER".GitHub context expressions used in
with:,if:,name:,body:, andref:contexts are left unchanged — those are action inputs / expression-engine contexts,
not shell, and are not injection vectors.
Why this is safe
With env-var indirection, untrusted values are passed to the shell as environment
variables rather than being substituted into the script text before execution, so
they can no longer break out of the intended command. This is the approach
recommended by GitHub's security hardening guidance for Actions.
Behavior
No functional change. This is a strict refactor from expression interpolation to
env-var indirection; the commands run exactly as before. Quoting the variables also
improves robustness for values containing spaces.
Verification
${{ github.event.inputs.* }}or${{ github.actor }}expressionsremain inside any
run:block..github/workflows/release.yml(1 file changed).