Repository navigation
ci(release): pass the tag through the environment, not into the script - #26
Merged
Merged
Conversation
The Parse version step pasted ${{ github.event.inputs.tag || github.ref_name }} into its
shell script, and the Verify version step pasted ${{ steps.meta.outputs.version }}, which
is the same tag without its leading v. A tag name is chosen by whoever pushes it, and
$(...) or a backtick is valid in a git ref, so such a tag ran as shell in the quality-gate
job. Only someone with write access can push a tag or dispatch the workflow, and the job
has only contents: read since the permissions change, so the reach was small; it is still
the pattern GitHub's own guidance says to avoid.
Both values now arrive as environment variables (TAG and TAG_VERSION) and the scripts use
"$TAG" and "$TAG_VERSION". The scripts are otherwise unchanged. Run with a tag of
v1.0.0$(touch PWNED), the old steps create the file and the new ones do not.
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
The
Parse versionstep of.github/workflows/release.ymlpasted${{ github.event.inputs.tag || github.ref_name }}into its shell script, and theVerify version matches tagstep pasted${{ steps.meta.outputs.version }}, which is the same tag without its leadingv. A tag name is chosen by whoever pushes it, and$(...)or a backtick is valid in a git ref, so such a tag ran as shell in thequality-gatejob.Both values now arrive as environment variables (
TAGandTAG_VERSION), and the scripts use"$TAG"and"$TAG_VERSION". Nothing else in the scripts changes.What changes
.github/workflows/release.yml: anenv:block on each of the two steps, and the two lines that interpolated the expressions are gone. They are the only two${{ }}expressions inside arun:script in the workflow (found by parsing the file).Test plan
actionlint .github/workflows/release.yml: clean.bash -e; for the old file the expression is substituted into the script text, for the new one the value is set in the environment), with the tagv1.0.0$(touch PWNED): the old steps create the filePWNED, the new ones do not, and the version output is the literal string. The newVerify version matches tagstep exits 1 on the mismatch, as it should.quality-gatefails on a version mismatch exactly as before.Security notes
quality-gatejob has onlycontents: read, so the reach was small. This closes the pattern regardless.env:is data to the shell; an expression pasted intorun:is code. The variables are read with shell syntax ("$TAG"), never re-expanded with${{ env.TAG }}inside the script.github-releasepasses the tag tosoftprops/action-gh-releaseas an action input, not through a shell script, and the third-party actions stay at floating tags.Borrow
Bug fix inside existing code, so there was no component to build. Checked locally: every
${{ }}expression inside arun:script in the workflow, by parsing the file (two). Read (from search results, not in full): GitHub's secure-use reference, which says to set the untrusted value in the step'senv:and read it with native shell syntax (https://docs.github.com/en/actions/reference/security/secure-use), and CodeQL's query help for code injection in Actions, which gives the same fix and warns against re-expanding the variable with${{ env.X }}(https://codeql.github.com/codeql-query-help/actions/actions-code-injection-medium/).