Skip to content

fix(ci): Use environment variables to prevent script injection in workflows#2200

Open
sky333999 wants to merge 1 commit into
mainfrom
sky333999/fix/script-injection-in-workflows
Open

fix(ci): Use environment variables to prevent script injection in workflows#2200
sky333999 wants to merge 1 commit into
mainfrom
sky333999/fix/script-injection-in-workflows

Conversation

@sky333999

@sky333999 sky333999 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description of changes

Move user-controlled context interpolations (inputs.*, matrix.*, github.event.*, needs.*.outputs.*, steps.*.outputs.*, toJSON, contains) out of shell run: and nick-fields/retry command: blocks into step-level env: bindings, then reference them as shell variables. This mirrors the pattern established in #1971.

Direct fixes across 23 workflows plus two indirect cases:

  • test-build-distributor.yml: job-level env: values derived from user inputs were referenced via ${{ env.X }} in run: blocks, which GitHub Actions expands at parse-time. Converted to shell-variable references ("$X").
  • test-build-docker.yml: Copy msi step runs on windows-2022 (PowerShell default); use $env:VARNAME instead of bash-style $VARNAME.

Also fixes three pre-existing correctness bugs surfaced during review:

  • test-artifacts.yml: elif if syntax error changed to valid elif [ ... ].
  • test-artifacts.yml: Terraform destroy retry fallback previously branched on matrix.arrays.os, but the corresponding apply steps branch on matrix.arrays.family. Aligned the destroy check to matrix.arrays.family so Windows-family cleanup cd's to terraform/ec2/win rather than falling through to the Linux path.
  • test-build-distributor.yml: LATEST_DEFAULT undefined variable typo changed to LATEST_VERSION.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

N/A

Requirements

Before commiting your code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

Integration Tests

To run integration tests against this PR, add the ready for testing label.

@sky333999
sky333999 requested a review from a team as a code owner July 14, 2026 16:15
@sky333999
sky333999 force-pushed the sky333999/fix/script-injection-in-workflows branch 2 times, most recently from 6adca7f to 7a6ca4f Compare July 14, 2026 16:41
@sky333999 sky333999 added the ready for testing Indicates this PR is ready for integration tests to run label Jul 15, 2026
varunch77
varunch77 previously approved these changes Jul 15, 2026
@sky333999
sky333999 force-pushed the sky333999/fix/script-injection-in-workflows branch from 48b4889 to 0160896 Compare July 16, 2026 17:35
…kflows

Move user-controlled context interpolations (inputs.*, matrix.*, github.event.*,
needs.*.outputs.*, steps.*.outputs.*, toJSON, contains) out of shell run: and
nick-fields/retry command: blocks into step-level env: bindings, then reference
them as shell variables. This mirrors the pattern established in PR #1971.

Direct fixes across 23 workflows plus two indirect cases:
- test-build-distributor.yml: job-level env: values derived from user inputs
  were referenced via ${{ env.X }} in run: blocks, which GitHub Actions expands
  at parse-time. Converted to shell-variable references ("$X").
- test-build-docker.yml: Copy msi step runs on windows-2022 (PowerShell
  default); use $env:VARNAME instead of bash-style $VARNAME.

Also fixes three pre-existing correctness bugs surfaced during review:
- test-artifacts.yml: elif if syntax error changed to valid elif [ ... ].
- test-artifacts.yml: Terraform destroy retry fallback previously branched on
  matrix.arrays.os but the corresponding apply steps branch on
  matrix.arrays.family. Aligned the destroy check to matrix.arrays.family so
  Windows-family cleanup cd's to terraform/ec2/win rather than falling through
  to the Linux path.
- test-build-distributor.yml: LATEST_DEFAULT undefined var typo changed to
  LATEST_VERSION.
@sky333999
sky333999 force-pushed the sky333999/fix/script-injection-in-workflows branch from 0160896 to 148f51c Compare July 16, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for testing Indicates this PR is ready for integration tests to run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants