ci: prevent script injection in Prerelease workflow - #192
Draft
laileni-aws wants to merge 1 commit into
Draft
Conversation
Bind user-controlled GitHub context values to step-level env vars instead of interpolating them directly into inline run: scripts: - github.event.inputs.tag_name (workflow_dispatch input) - github.ref_name (feature/* and release/* branch handling) Following GitHub Actions security-hardening guidance, the values are now passed via env: and referenced as quoted shell variables, so a crafted branch name or dispatch input can no longer be interpreted as script. Resolves ACAT/GithubWorkflowIdentifier finding (script injection in GitHub Actions workflows).
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 an ACAT/AppSec script injection finding in
.github/workflows/release.yml(the Prerelease workflow). Three user-controlled GitHub context values were interpolated directly via${{ }}into inlinerun:scripts. An attacker who controls aworkflow_dispatchinput or pushes a branch with a crafted name could inject arbitrary shell commands into a job that runs withcontents: write.github.event.inputs.tag_namerun: echo "TAG_NAME=..."workflow_dispatchgithub.ref_namefeature/*handlingpushgithub.ref_namerelease/*handlingpushFix
Per GitHub Actions security-hardening guidance, each untrusted value is now bound to a step-level
env:variable and referenced as a quoted shell variable ($TAG_NAME_INPUT,"$REF_NAME"). Environment values are passed to the shell as data rather than expanded into script text, which removes the injection vector. No behavior change for legitimate inputs.Testing
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/release.yml'))"-> parses OK${{ github.* }}interpolation remains inside anyrun:block; the remaining references are all insideenv:blocks (the safe pattern).