Skip to content

ci: pass release tag values through env vars on v2 - #1446

Merged
TerryHowe merged 1 commit into
oras-project:v2from
akashchamp:chore/v2-release-tag-env-vars
Sep 24, 2026
Merged

TerryHowe merged 1 commit into
oras-project:v2from
akashchamp:chore/v2-release-tag-env-vars

Conversation

@akashchamp

Copy link
Copy Markdown

Fixes #1442.

release.yml's "Create and push tag" step interpolates ${{ steps.version.outputs.version }} and ${{ github.event.pull_request.merge_commit_sha }} directly into the run: shell block. This is the same class of template-injection risk that PR #1264 already fixed on main for the v1 release workflow, and PR #1439 fixed for the rest of this step's siblings on v2 โ€” this issue is the one remaining follow-up, filed by @TerryHowe after closing #1440 in favor of tracking it here.

This PR applies the identical fix, scoped only to this one step: pass both values through env: and reference them as quoted shell variables ("$VERSION", "$MERGE_COMMIT") instead of interpolating the ${{ }} expressions straight into the script. The resulting step is byte-for-byte identical to the equivalent step already merged on main.

Verification performed

  • actionlint .github/workflows/release.yml and actionlint against the full .github/workflows/ directory: clean, no findings.
  • YAML validity: python3 -c "import yaml; yaml.safe_load(open('.github/workflows/release.yml'))" parses without error.
  • git diff --check: no whitespace/encoding issues; git status --short confirms only this one file changed.
  • Diffed the modified step against the equivalent step on main (fetched via FETCH_HEAD): output empty โ€” identical.
  • Functional equivalence (executed, not just read): built a disposable local git repo + bare remote, exported VERSION="v1.2.3" and MERGE_COMMIT=<real commit sha> as env vars, and ran the new script's exact commands (git tag "$VERSION" "$MERGE_COMMIT"; git push origin "$VERSION") verbatim. git ls-remote --tags origin confirmed the tag was created and pushed correctly โ€” normal behavior is unchanged.
  • The security property itself (executed): spliced a crafted version string (v1.2.3; touch /tmp/pwned-oras-demo #) directly into the old pattern (git tag <value> <sha> with the value substituted unquoted, mirroring literal ${{ }} template substitution before bash parses it) and ran it โ€” the injected touch genuinely executed. Ran the identical malicious string through the new pattern (git tag "$VERSION" "$MERGE_COMMIT" with VERSION set via env var) โ€” the injected command did not execute; the whole string was passed as a single inert argument to git tag, which errored on an invalid ref name instead. Demo artifact removed afterward.

AI assistance

This project has no AI-assistance disclosure policy in CONTRIBUTING.md, AGENTS.md, or the PR template. Disclosing anyway: this change was prepared with Claude (Claude Code) assistance under the account holder's direction and review before submission.

Signed-off-by: Akash Kumar 116457960+akashchamp@users.noreply.github.com

The "Create and push tag" step interpolated
${{ steps.version.outputs.version }} and
${{ github.event.pull_request.merge_commit_sha }} directly into the
script body. The runner substitutes that text before bash parses the
line, so the step's safety rested on the extraction regex above it
staying strict. Pass both values through env: and quote them instead,
matching the equivalent step on main (oras-project#1264).

No behavior change: the anchored title regex already constrains the
captured version to semver, so nothing reaching this step could have
exploited the interpolation today. This is defense in depth, not a
fix for a live issue.

Closes oras-project#1442

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Akash Kumar <116457960+akashchamp@users.noreply.github.com>

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit 339ecf8 into oras-project:v2 Sep 24, 2026
1 check passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants