Skip to content

🔒 fix(release): pass workflow inputs via env: to neutralize script injection (CI-9) - #120

Merged
konih merged 1 commit into
mainfrom
fix/ci9-release-script-injection
Jul 14, 2026
Merged

konih merged 1 commit into
mainfrom
fix/ci9-release-script-injection

Conversation

@konih

@konih konih commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

CI-9 — Harden the release pipeline against GitHub Actions expression injection

Resolves backlog CI-9 / INBOX decision D-2026-07-13-ci9 (option A: harness implements, no auto-merge — you merge after eyeballing the release-workflow diff).

Problem

SonarCloud flagged githubactions:S7630 (BLOCKER) at release.yaml:42 plus the S8264 family: ${{ … }} expressions were interpolated directly into run: script bodies. The worst case — TAG="${{ inputs.tag }}" — is substituted before the shell runs, so a crafted workflow_dispatch tag like v1.0.0"; echo pwned; " breaks out of the quotes and executes in a job holding contents: write + packages: write + id-token: write (cosign signing identity). The vX.Y.Z regex validated only after the injection point.

Fix

Every ${{ … }} expression is moved out of run: bodies into the step's env: block and referenced as a quoted shell variable — the pattern already proven in-repo at release-gate.yaml (INPUT_SHA). Untrusted input now reaches the shell as literal data; metacharacters can't execute, and the vX.Y.Z regex rejects a hostile tag before any asset is built, signed, or published.

  • .github/workflows/release.yaml — Resolve version (the BLOCKER), image, Sign container image, Build release assets, Export provenance, chart, Publish & sign Helm chart.
  • .github/workflows/release-gate.yaml — Wait for required check-runs + manual-e2e-checklist.
  • Workflow-level env.REGISTRY/env.IMAGE_NAME stay auto-exposed as $REGISTRY/$IMAGE_NAME — behavior preserved.
  • Out of scope (intentional): release.yaml:36 checkout ref: — a with:-level action input resolving a git ref via format(), not a shell sink.

Verification

  • Done-when gate met: zero ${{ }} remain in any run: body in either file.
  • Injection proof: ran the hardened Resolve version logic with tag='v1.0.0"; echo PWNED > marker; "' → payload stayed literal, no execution (no marker file), validation rejected it with the literal string echoed.
  • Gates green: task verify · task lint (golangci 0 issues, arch:lint green) · task test:run (internal/ 93.0%) · task lint:markdown · actionlint (both workflows). No uses: SHA-pin changes.
  • Review: /mkurator-review → APPROVE (0 P0/P1/P2; one P3 doc-wording nit addressed in this branch).
  • Docs: env-var discipline documented in docs/CICD.md (Principles) + docs/RELEASE.md.

⚠️ Do not auto-merge — release-pipeline + security-sensitive. Confirmation that S7630/S8264 clear is pending the SonarCloud check on this PR (actionlint validates syntax, not Sonar's ruleset).

…jection (CI-9)

Resolve SonarCloud githubactions:S7630 (BLOCKER, release.yaml:42) + the S8264 family: no ${{ }} expression is interpolated inside any run: block in release.yaml / release-gate.yaml. Untrusted context (notably the workflow_dispatch `tag` input) now reaches the shell only as env: variables, so metacharacters stay literal data and the vX.Y.Z regex rejects a hostile tag before any release step runs. Docs: env-var discipline noted in CICD.md + RELEASE.md.
@konih

konih commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

REVIEW — ci9-release-script-injection @ eff65b8 → fd42ab3 — APPROVE — 2026-07-13

/mkurator-review (tech-reviewer, MKurator gate set). 0 P0/P1/P2 findings.

Gates: actionlint (both workflows) ✅ · YAML parse ✅ · no ${{ }} in any run: body ✅ (all 40 exprs in release.yaml + 22 in release-gate.yaml sit in env:/with:/if:/ref:/job-output positions) · uses: SHA pins unchanged ✅ · no secrets in diff ✅. Go gates (verify/lint/test:run 93.0%/markdown) author-reported green, not replayed — no Go delta (YAML+docs only).

Correctness: injection neutralized — inputs.tag enters via TAG_INPUT env and is assigned as literal data; vX.Y.Z regex preserved and runs post-assignment. Behavior preserved across every converted step (env var names consistent; workflow-level env.REGISTRY/IMAGE_NAME still auto-exposed as shell vars; release-assets.sh positional contract unchanged). Out-of-scope with:-level exprs (incl. release.yaml:36 checkout ref:) correctly untouched.

F1 (P3, non-blocking, addressed): RELEASE.md wording tightened — the checkout consumes the raw ref via format() before regex validation; clarified that validation gates asset build/sign/publish, not the initial ref resolution.

Verdict: APPROVE. Reviewer does not authorize or self-approve the merge — maintainer merges. Sonar S7630/S8264 clearance confirms on this PR's SonarCloud check.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@konih
konih merged commit 32aed5a into main Jul 14, 2026
18 checks passed
@konih
konih deleted the fix/ci9-release-script-injection branch July 14, 2026 11:08
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.

1 participant