Guard against shell injection via github.ref in image workflow - #6248
Merged
Conversation
"${{ github.ref }}" and "${{ github.ref_name }}" were interpolated
directly into bash if/elif checks and variable assignments across
image-build-and-publish.yml. Git ref names can contain shell
metacharacters, so a maliciously named branch or tag could inject
commands into these steps when the workflow is reached via
workflow_dispatch or a published release.
Use the runner's default $GITHUB_REF / $GITHUB_REF_NAME environment
variables instead, so ref values are passed as data rather than
expanded into the script text before the shell runs.
Addresses GHSA-g976-wp3r-q8c6.
JAORMX
approved these changes
Aug 10, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6248 +/- ##
=======================================
Coverage 72.70% 72.71%
=======================================
Files 742 742
Lines 77273 77273
=======================================
+ Hits 56184 56188 +4
+ Misses 17131 17126 -5
- Partials 3958 3959 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
approved these changes
Aug 10, 2026
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
image-build-and-publish.ymlinterpolated${{ github.ref }}/${{ github.ref_name }}directly into bashif/elifchecks and variable assignments. Git ref names can legally contain shell metacharacters ($,`,(,),;, etc.), so a maliciously-named branch or tag could inject commands into these steps. The steps run withpackages: writeandid-token: writepermissions (GHCR push + Cosign signing), so the blast radius is our image-signing/publish credentials.workflow_dispatch(any existing ref) or a published release (tag name), both of which require push/release access to the repo. Not reachable viapull_request/fork PRs — the workflow isworkflow_call-only.$GITHUB_REF/$GITHUB_REF_NAMEenvironment variables in the shell instead of expression interpolation, so the ref value is passed as data rather than expanded into the script text before the shell runs. Noenv:block changes needed — these are already provided automatically by the Actions runner.Type of change
Test plan
Validated the workflow YAML parses correctly (
python3 -c "import yaml; yaml.safe_load(...)"). No Go code touched, sotask test/task lint-fixdon't apply; there's no repo lint step covering workflow YAML. Confirmed viagrepthat all shell-contextgithub.ref/github.ref_nameusages in this file are addressed, and that the remaininggithub.refusages (inif:conditions and an action'swith:input in the egress-proxy job) are pure Actions-expression contexts, not shell, so they're not part of this vulnerability class and were left untouched.Does this introduce a user-facing change?
No.
Special notes for reviewers