Skip to content

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

Closed
sky333999 wants to merge 4 commits into
aws:mainfrom
sky333999:fix/script-injection-in-workflows
Closed

fix(ci): Use environment variables to prevent script injection in workflows#2191
sky333999 wants to merge 4 commits into
aws:mainfrom
sky333999:fix/script-injection-in-workflows

Conversation

@sky333999

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 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 two pre-existing bugs surfaced during review:

  • test-artifacts.yml: elif if syntax error changed to valid elif [ ... ].
  • test-build-distributor.yml: LATEST_DEFAULT undefined var 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 9, 2026 20:30
…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 aws#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 fix/script-injection-in-workflows branch from 93c92d4 to 9308394 Compare July 9, 2026 22:58
@sky333999 sky333999 added the ready for testing Indicates this PR is ready for integration tests to run label Jul 13, 2026
@sky333999

Copy link
Copy Markdown
Contributor Author

Superseded by #2200 — same commit, moved to a branch on this repo (aws/amazon-cloudwatch-agent) instead of a fork so CI runs have access to repo secrets and OIDC. Closing this PR; please review the new one.

@sky333999 sky333999 closed this Jul 14, 2026
@sky333999 sky333999 deleted the fix/script-injection-in-workflows branch July 14, 2026 16:16
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.

1 participant