Skip to content

fix(workflow): pass github.ref_name via env to fix Semgrep shell-injection block - #229

Merged
0xmariowu merged 2 commits into
mainfrom
fix/semgrep-shell-injection-ref-name
May 24, 2026
Merged

fix(workflow): pass github.ref_name via env to fix Semgrep shell-injection block#229
0xmariowu merged 2 commits into
mainfrom
fix/semgrep-shell-injection-ref-name

Conversation

@0xmariowu

Copy link
Copy Markdown
Owner

Summary

Why it matters

github.ref_name for tag-triggered workflows is attacker-controllable in the abstract (a malicious push of a tag named $(curl evil) would inject). Quoting the env var defuses that.

Test plan

  • bash scripts/lib/check-template-sync.sh → PASS
  • bash tests/test_compliance.sh → 4/4 PASS
  • bash tests/test-scanner.sh → 118/118 PASS
  • grep -rn 'github\.ref_name' .github/ templates/ → only env: references remain (no run: interpolation)
  • CI Semgrep job → expect 0 blocking findings

Unblocks

Once merged, rebase the 3 open PRs and Semgrep should go green:

Move `github.ref_name` interpolation out of `run:` blocks into `env:`,
then reference the env var with quoted `"$REF_NAME"` in the shell.

Resolves 5 Semgrep blocking findings (yaml.github-actions.security
.run-shell-injection.run-shell-injection) currently failing every PR
on main, including dependabot bumps and unrelated infra work.

Same fix applied to templates/universal/release.yml so the user-facing
template stays in sync (per CLAUDE.md template-sync rule;
scripts/lib/check-template-sync.sh passes).
Copilot AI review requested due to automatic review settings May 24, 2026 12:28
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@0xmariowu, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 29 minutes and 30 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e66f5656-505c-4ec2-aa7c-367ca107b6f7

📥 Commits

Reviewing files that changed from the base of the PR and between 1ada0b9 and 8bc9297.

📒 Files selected for processing (2)
  • .github/workflows/release.yml
  • templates/universal/release.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Semgrep run-shell-injection findings in the release workflows by avoiding direct ${{ github.ref_name }} interpolation inside run: blocks, while keeping the repository’s release workflow and the user-facing release template in sync.

Changes:

  • Hoists github.ref_name into step env: and references it from shell variables ("$REF_NAME") in .github/workflows/release.yml.
  • Applies the same adjustment in templates/universal/release.yml to prevent template-sync drift.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/release.yml Replaces direct ${{ github.ref_name }} usage inside run: blocks with a step env var reference.
templates/universal/release.yml Mirrors the same ref_name handling change in the universal release template.
Comments suppressed due to low confidence (3)

.github/workflows/release.yml:363

  • This workflow already uses GITHUB_REF_NAME elsewhere. Using it here would avoid repeating REF_NAME: ${{ github.ref_name }} across steps and keeps tag naming consistent within the file.
        env:
          GH_TOKEN: ${{ github.token }}
          REF_NAME: ${{ github.ref_name }}
        run: |
          TAG="$REF_NAME"

.github/workflows/release.yml:410

  • Same as above: prefer the built-in GITHUB_REF_NAME over a separate REF_NAME env var for consistency and less duplication.
        env:
          GH_TOKEN: ${{ github.token }}
          REF_NAME: ${{ github.ref_name }}
        run: |
          TAG="$REF_NAME"

.github/workflows/release.yml:462

  • The step can use the built-in GITHUB_REF_NAME directly (already used earlier in the workflow) and drop the extra REF_NAME env block.
        env:
          REF_NAME: ${{ github.ref_name }}
        run: |
          TAG="$REF_NAME"

Comment thread .github/workflows/release.yml Outdated
Comment thread templates/universal/release.yml Outdated
…nv var

Address Copilot review on #229: the runner already provides
$GITHUB_REF_NAME, which is used by earlier steps in the same workflow.
Drop the redundant `REF_NAME: ${{ github.ref_name }}` env hop and
reference the built-in variable directly. Same change applied to
templates/universal/release.yml for consistency.

Still fixes the Semgrep run-shell-injection findings (no ${{ ... }}
interpolation inside run: blocks).
@0xmariowu
0xmariowu merged commit 74fdf74 into main May 24, 2026
23 checks passed
@0xmariowu
0xmariowu deleted the fix/semgrep-shell-injection-ref-name branch May 24, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants