Fix: Env-mediate expressions in run blocks - #104
Merged
tykeal merged 1 commit intoJul 28, 2026
Merged
Conversation
zizmor's auditor persona reported 10 template-injection findings in testing.yaml: GitHub expressions expanded directly inside 'run:' blocks, where expansion happens before the shell sees the script and a crafted value could inject commands. Two steps were affected, both reading outputs of the generate-sbom step: the debug dump and the validation step. The validation step already declared an 'env:' block for its matrix values, so the SBOM outputs join it there. Names are kept short (SBOM_MANAGER, SBOM_COUNT) because the step id is long enough that the fuller names push the lines past the 80-column limit yamllint enforces here. The org-wide zizmor workflow now fails a run on any finding at any level, so these informational findings block every new pull request in this repository. zizmor offers an auto-fix for this audit, but it is marked unsafe and on inspection it is: it rewrites the expression in place, leaving it inside the original single quotes, where the shell will not expand it. The original was correct because GitHub expanded the template before the shell ever saw it. These edits were therefore written by hand, with double quotes, and follow the env-before-run shape already used elsewhere in this repository. No behavioural change: the same values reach the same commands. Zizmor now reports no findings for the repository. Co-authored-by: Claude <claude@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copilot started reviewing on behalf of
ModeSevenIndustrialSolutions
July 28, 2026 14:55
View session
There was a problem hiding this comment.
Pull request overview
This PR hardens the CI workflow against GitHub Actions template-injection findings by ensuring steps.generate-sbom.* expressions are not expanded directly inside run: scripts, instead passing them through step-scoped env: variables.
Changes:
- Added step
env:mappings forgenerate-sbomoutcome and outputs in the SBOM debug step. - Added the same SBOM-related
env:mappings to the validation step (joining its existing matrixenv:block). - Updated the bash scripts to reference
$SBOM_*variables instead of${{ ... }}expressions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zxiiro
approved these changes
Jul 28, 2026
zxiiro
left a comment
Contributor
There was a problem hiding this comment.
🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. Mediates GitHub Actions expressions (step outputs) through env: vars instead of direct ${{ }} interpolation in shell run: steps, in test/CI workflow only; standard injection-hardening pattern, no new permissions or secrets.
tykeal
approved these changes
Jul 28, 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.
Why
The org-wide zizmor workflow (
lfreleng-actions/.github/workflows/zizmor.yaml) was changed today:It runs
--persona auditor --min-severity informationaland now fails a run on any finding at any level. This repo carries 10 pre-existingtemplate-injectionfindings — the most of any repo I've looked at — so every new PR here is blocked until they're cleared, currently #103.What
.github/workflows/testing.yamlexpandedgenerate-sbomoutputs directly insiderun:blocks. GitHub expands${{ }}before the shell sees the script, so a crafted value becomes shell source text rather than data. Routing throughenv:makes the value opaque to the shell parser.Two steps were affected — the debug dump and the validation step. The validation step already declared an
env:block for its matrix values, so the SBOM outputs simply join it:Same shape
python-workflowsuses (see its "Fix: Env-mediate expressions in run blocks"), and theenv:-before-run:ordering already used elsewhere here.On naming:
python-workflowsusedSBOM_COMPONENT_COUNT/SBOM_DEPENDENCY_MANAGER. Here the step id isgenerate-sbomrather thansbom, which pushes those lines past the 80-column limityamllintenforces in this repo. I shortened toSBOM_COUNT/SBOM_MANAGERrather than scatter# yamllint disable-linesuppressions.zizmor offers an auto-fix for this audit. It is marked unsafe, and on inspection it is: it rewrites expressions in place while leaving them inside their original quoting, and the shell does not expand
${...}inside single quotes. The original code was correct precisely because GitHub expanded the template before the shell ran; once the value moves toenv:, expansion becomes the shell's job and the quoting has to change with it.This repo's call sites happened to use double quotes so the auto-fix would have survived here — but it silently breaks sibling repos, so all of these were done by hand and re-verified.
The auto-fix also emitted a duplicated
env:block on one step, which is a second reason not to take its output verbatim.Validation
zizmor --persona auditor --min-severity informational→ No findings to reportpre-commit run --all-files→ all hooks pass, includingyamllintandactionlintUnblocks #103.