fix(terraform): prevent script injection via env var isolation#2679
Open
herdiyana256 wants to merge 1 commit into
Open
fix(terraform): prevent script injection via env var isolation#2679herdiyana256 wants to merge 1 commit into
herdiyana256 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
4885908 to
9c823e5
Compare
Pass tj-actions/changed-files outputs through env: block variables
instead of inline ${{ }} interpolation in bash run: scripts.
GitHub Actions evaluates ${{ }} expressions before shell execution.
When outputs contain shell metacharacters (e.g. $(...), `...`),
bash evaluates them as commands - a script injection vulnerability.
Vulnerable pattern:
run: |
CHANGED="${{ steps.changed-files.outputs.all_changed_files }}"
Fixed pattern:
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
CHANGED="$ALL_CHANGED_FILES"
When passed via env:, the ${{ }} expression is assigned as a plain
string to the environment variable before the shell starts. The shell
never evaluates metacharacters in the value.
Ref: https://securitylab.github.com/research/github-actions-untrusted-input/
Ref: go/github-security
9c823e5 to
bd76501
Compare
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.
Summary
Audit of
.github/workflows/identified two files where GitHub Actions expressions (${{ }}) are interpolated directly into bashrun:scripts. This is the script injection class documented by GitHub Security Lab.This PR applies the recommended mitigation across all affected steps:
pass expression values through
env:block variables instead of inline interpolation. When assigned viaenv:, the value is treated as a plain string by the shell — metacharacters are never evaluated as commands.Files Changed
1.
.github/workflows/terraform.yml— Critical (3 fixes)Fix 1 - Env var isolation for
tj-actions/changed-filesoutputsThe
Extract Orgsstep interpolated action outputs directly into bash: