fix(ci): prevent script injection in trigger-codepipeline workflow - #1111
Draft
laileni-aws wants to merge 1 commit into
Draft
fix(ci): prevent script injection in trigger-codepipeline workflow#1111laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
The head_commit.author.name context value was interpolated directly via
${{ }} into the inline run: script. A commit author name is user-controlled,
so a crafted name containing shell metacharacters could inject arbitrary
commands. The job holds id-token: write and assumes GitHubActionsCodePipelineRole,
so injected commands would run with AWS credentials able to start CodePipeline.
Bind the value to a step-level env var and reference it as a quoted shell
variable ($COMMIT_AUTHOR), per GitHub Actions security-hardening guidance.
The value is passed to the shell as data rather than expanded into script
text. No behavior change for legitimate commits.
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/trigger-codepipeline.yml(lines 24-26). Thegithub.event.head_commit.author.namecontext value was interpolated directly via${{ }}into the inlinerun:script.A commit author name is user-controlled — an attacker can craft a commit whose author name contains shell metacharacters (e.g.
$(...)or"; ...; "). When that commit lands onmain, the workflow runs the injected command. This job hasid-token: writeand assumesGitHubActionsCodePipelineRole, so injected commands would execute with AWS credentials able to start CodePipeline.Fix
Per GitHub Actions security-hardening guidance, the value is now bound to a step-level
env:variable and referenced as a quoted shell variable ($COMMIT_AUTHOR). 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 commits.Note: the
if:condition on the job also referenceshead_commit.author.name, but that is a GitHub Actions expression (evaluated by the expression engine, not the shell), so it is not an injection vector and is unchanged.Testing
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/trigger-codepipeline.yml'))"-> parses OK${{ github.* }}interpolation remains inside therun:block.