Repository navigation
[automated] Prevent template injection in handwritten GitHub workflows - #21033
Ankit Jain (radical) wants to merge 6 commits into
Conversation
Workflow inputs and outputs were interpolated into executable shell and JavaScript source. Quotes or shell substitutions in those values could change the commands being run instead of remaining literal data. Pass values through environment variables and parse argument strings into literal arrays without evaluating shell syntax. Transport the expanded test matrix through files so it stays out of executable here-strings and per-variable OS size limits. Exercise argument parsing, enumeration, large-matrix transport, and CI routing behavior through standalone scripts. Zizmor 1.31.0 reports 127 fewer template-injection findings; the remaining 18 generated-workflow findings are deferred to microsoft#21031. Refs microsoft#21031 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bc572840-cb86-4d09-829a-68af89cdce3e
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21033Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21033" |
There was a problem hiding this comment.
🟡 Changes recommended
Windows batch wrappers still reinterpret parsed arguments, and the extension version override reads an unset PowerShell variable.
3 open findings
What changed in this PR
Hardens Aspire’s handwritten GitHub workflows against template injection. Generated agentic workflows remain deferred to #21031.
Changes:
- Passes dynamic values through environment variables and parses argument strings as data.
- Moves large test matrices through files.
- Adds behavioral regression tests and CI selection rules.
| File | Description |
|---|---|
| tests/Infrastructure.Tests/WorkflowScripts/TemplateInjectionTests.cs | Tests argument parsing and matrix transport. |
| tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs | Verifies shared-script CI routing. |
| eng/github-ci/test-trigger-map.yml | Routes shared scripts to all consumers. |
| .github/workflows/write-test-matrix.ps1 | Copies matrices with an empty fallback. |
| .github/workflows/update-nix-cli-flake.yml | Passes release inputs through environment variables. |
| .github/workflows/tests.yml | Uses file-based matrix transport. |
| .github/workflows/specialized-test-runner.yml | Parses arguments and isolates dynamic values. |
| .github/workflows/run-tests.yml | Revises build and test argument forwarding. |
| .github/workflows/reproduce-flaky-tests.yml | Parses filters and isolates reproduction inputs. |
| .github/workflows/release-github-tasks.yml | Isolates release inputs from shell source. |
| .github/workflows/README.md | Documents input handling and matrix transport. |
| .github/workflows/polyglot-validation.yml | Quotes dynamic Docker arguments. |
| .github/workflows/parse-command-line.py | Adds literal argument parsing. |
| .github/workflows/labeler-predict-pulls.yml | Reads workflow names from the environment. |
| .github/workflows/homebrew-validate-release.yml | Isolates version and cask-path values. |
| .github/workflows/extension-unit-tests.yml | Moves version overrides into the environment. |
| .github/workflows/extension-e2e-tests.yml | Reads artifact URLs from the environment. |
| .github/workflows/enumerate-test-metadata.sh | Extracts metadata enumeration with argument arrays. |
| .github/workflows/deployment-tests.yml | Parses test arguments and isolates matrix values. |
| .github/workflows/build-packages.yml | Parses version override arguments. |
| .github/workflows/build-cli-native-archives.yml | Revises native build argument forwarding. |
| .github/workflows/backport.yml | Reads target branches through process.env. |
| .github/workflows/backmerge-release.yml | Isolates commit counts from executable source. |
| .github/actions/unlock-macos-keychain/action.yml | Quotes environment-backed keychain inputs. |
| .github/actions/enumerate-tests/action.yml | Parses build arguments and writes matrix files. |
| .github/actions/check-changed-files/action.yml | Reads the patterns path from the environment. |
🧠 Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Reusable workflow inputs were expanded into executable shell and JavaScript source. Parsing extra arguments did not close the Windows boundary: build.cmd reparsed them in powershell -Command, and dotnet.cmd forwarded them through CALL. Transport workflow values through environment variables, parse argument strings without evaluation, and invoke eng/build.ps1 or the selected SDK executable directly instead of forwarding parsed arguments through batch wrappers. Transport generated test matrices through files to avoid environment variable size limits. Exercise production build steps through their PowerShell forwarding boundary and add native Windows SDK argument-capture coverage. Route the shared workflow helpers to their test consumers. Run only the five Windows forwarding cases in the existing x64 native archive job and require five fresh passed results. Admit reproducer changes to CI so those inputs cannot bypass the regression. Refs microsoft#18036 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Workflow-script tests can pass despite broken environment mappings, and missing platform-specific Python prerequisites can cause eligible tests to fail unexpectedly.
4 open issues
1 resolved since last review
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Windows archive dependencies can build successfully without producing BuildBundleDeps.log, causing the subsequent copy and warning check to fail. In-process PowerShell invocation does not pipe Arcade's inherited native console handles through Tee-Object; redirecting PowerShell's other streams alone still loses native warnings. Run Windows builds through pwsh -NoProfile -File so the child process output reaches the existing log pipeline. Preserve literal argument arrays, explicit exit handling and the native warning verification. Remove the reconstructed workflow-fragment forwarding, receipt and admission fixtures and their dedicated Windows lane. Keep the direct parser, enumeration and matrix-script tests, actual security-helper routing, and existing native archive builds. The removed fixtures reconstruct YAML bodies rather than execute complete production entries. Refs microsoft#18036 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The Windows-only tests are excluded from normal CI and cover only Python parsing, leaving the new PowerShell and dotnet argument-forwarding boundaries without regression coverage.
3 open issues
2 resolved since last review
Review effort: Balanced
Keep test metadata enumeration and matrix-file transport in their existing action and workflow consumers. Retain the shared argument parser because multiple entry points use its literal argument arrays. Preserve environment-backed inputs, file-backed matrix outputs, and the Windows child-process logging boundary. Limit runtime-input routing to the shared parser rather than single-consumer script files. Refs microsoft#18036 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive changes to Windows process boundaries and native-output capture need confirmation from pending CI that archive builds preserve dependency logs and execute the native-warning gate.
2 open issues
1 resolved since last review
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Integrate the shared Bundle.proj packaging flow without reintroducing Windows batch-wrapper reparsing. Parse version overrides into literal argument arrays and invoke the SDK selected by InitializeDotNetCli through dotnet.exe. Preserve MSBuild-owned Dashboard warning verification and update the workflow documentation for the remaining test-build log capture. Refs microsoft#21888 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive Windows argument-forwarding changes need human validation because passing CI does not establish literal native argument preservation or execution of the archive and reproducer branches.
2 open issues
1 resolved since last review
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-platform security changes span shell, JavaScript, and native-process boundaries, with crafted-argument forwarding, reproducer execution, and matrix fallback paths still unverified and requiring human review.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
Restore the existing explanation and documentation link for why release checks use the App token. A read-only token cannot see drafts, so using it would make release retries miss an existing draft. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because parser-only changes skip the independent quarantine and outerloop workflows, leaving their runsheet-argument handling unvalidated.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
86505c0cd58cc13f08baa1d93b5b8bdea08b78dbDescription
Zizmor flags workflow values embedded in executable shell or JavaScript; on Windows, quoted argument arrays can also regain command meaning downstream.
build.cmdforwards throughpowershell -Command, anddotnet.cmdthroughCALL, allowing values such as$()or&to be reinterpreted.This change transports workflow values through environment variables instead of executable interpolation and parses extra argument strings without evaluation. Windows test/reproducer builds use child
pwsh -NoProfile -File eng/build.ps1; SDK calls invoke the repository-selected executable directly. The child boundary also preserves native build output in logs. Matrix contents pass through files rather than executable source or environment variables.Argument strings use POSIX-style tokenization on every OS: no variable expansion, command substitution or glob expansion; malformed quoting fails explicitly. This removes the interpolation and batch-wrapper boundaries, not all downstream interpretation.
Relates to #21888.
Validation
The final diff adds the
SharedArgumentParserSelectsAllConsumersrouting regression test; 188 targeted selector tests passed. Argument/scenario checks below are execution evidence, not permanent forwarding tests in this PR.$(whoami),x&whoamiand spaced values through the ordinary no-package Windows x64 path.The native/reproducer runs are isolated fork validation atop the assessed revision, not source-head CI runs; production run blocks and build scripts were unchanged. Both selected reviewers accepted their bounded evidence.
Limits: both receiver receipts come from the same final test host. Three literal input classes do not prove arbitrary quoting/Unicode safety; no-.NET/empty-matrix fallbacks and failed-child/failing-iteration negative controls remain unexecuted. Scanner findings remain, and local parser/ShellCheck limitations are not a clean-scan claim.
Checklist
<remarks />and<code />elements on your triple slash comments?