Repository navigation
🔒 fix(release): pass workflow inputs via env: to neutralize script injection (CI-9) - #120
Conversation
…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.
REVIEW — ci9-release-script-injection @
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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) atrelease.yaml:42plus theS8264family:${{ … }}expressions were interpolated directly intorun:script bodies. The worst case —TAG="${{ inputs.tag }}"— is substituted before the shell runs, so a craftedworkflow_dispatchtag likev1.0.0"; echo pwned; "breaks out of the quotes and executes in a job holdingcontents: write+packages: write+id-token: write(cosign signing identity). ThevX.Y.Zregex validated only after the injection point.Fix
Every
${{ … }}expression is moved out ofrun:bodies into the step'senv:block and referenced as a quoted shell variable — the pattern already proven in-repo atrelease-gate.yaml(INPUT_SHA). Untrusted input now reaches the shell as literal data; metacharacters can't execute, and thevX.Y.Zregex 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.env.REGISTRY/env.IMAGE_NAMEstay auto-exposed as$REGISTRY/$IMAGE_NAME— behavior preserved.release.yaml:36checkoutref:— awith:-level action input resolving a git ref viaformat(), not a shell sink.Verification
${{ }}remain in anyrun:body in either file.Resolve versionlogic withtag='v1.0.0"; echo PWNED > marker; "'→ payload stayed literal, no execution (no marker file), validation rejected it with the literal string echoed.task verify·task lint(golangci 0 issues, arch:lint green) ·task test:run(internal/ 93.0%) ·task lint:markdown·actionlint(both workflows). Nouses:SHA-pin changes./mkurator-review→ APPROVE (0 P0/P1/P2; one P3 doc-wording nit addressed in this branch).docs/CICD.md(Principles) +docs/RELEASE.md.