Skip to content

Fix shell injection vulnerability in GitHub Actions workflow [SEC-1714]#1456

Merged
spencerdrak merged 1 commit intodevelopfrom
semgrep-autofix/1774326297
Mar 24, 2026
Merged

Fix shell injection vulnerability in GitHub Actions workflow [SEC-1714]#1456
spencerdrak merged 1 commit intodevelopfrom
semgrep-autofix/1774326297

Conversation

@semgrep-zcs-prod-semgrep
Copy link
Copy Markdown

Fix potential shell injection vulnerability in the semgrep-ci-e2e workflow by using an environment variable instead of direct interpolation.

Changes

  • Modified the Debug step to use an env: block for the docker_tag output
  • Changed the run: script to reference the quoted environment variable "$DOCKER_TAG" instead of using direct ${{ }} interpolation

Why

Direct interpolation of ${{ steps.get-inputs.outputs.docker_tag }} in the run: script is vulnerable to command injection. If the docker_tag value contains shell metacharacters or malicious commands, they would be executed by the runner. By storing the value in an environment variable first and referencing it with double quotes, the value is treated as a literal string rather than being interpreted by the shell.

Semgrep Finding Details

Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".

@leif@semgrep.com requested Semgrep Assistant generate this pull request to fix a finding from the detection rule yaml.github-actions.security.run-shell-injection.run-shell-injection.


⚠️ Review carefully before merging. This PR was generated by AI and may cause breaking changes or introduce new vulnerabilities.

Fix potential shell injection vulnerability in the semgrep-ci-e2e workflow by using an environment variable instead of direct interpolation.

## Changes
- Modified the Debug step to use an `env:` block for the `docker_tag` output
- Changed the `run:` script to reference the quoted environment variable `"$DOCKER_TAG"` instead of using direct `${{ }}` interpolation

## Why
Direct interpolation of `${{ steps.get-inputs.outputs.docker_tag }}` in the `run:` script is vulnerable to command injection. If the `docker_tag` value contains shell metacharacters or malicious commands, they would be executed by the runner. By storing the value in an environment variable first and referencing it with double quotes, the value is treated as a literal string rather than being interpreted by the shell.

## Semgrep Finding Details
Using variable interpolation `${{...}}` with `github` context data in a `run:` step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. `github` context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with `env:` to store the data and use the environment variable in the `run:` script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".

@leif@semgrep.com requested Semgrep Assistant generate this pull request to fix [a finding](https://semgrep.dev/orgs/semgrep/findings/679965828) from the detection rule [yaml.github-actions.security.run-shell-injection.run-shell-injection](https://semgrep.dev/r/yaml.github-actions.security.run-shell-injection.run-shell-injection).
@leifdreizler leifdreizler changed the title Fix shell injection vulnerability in GitHub Actions workflow Fix shell injection vulnerability in GitHub Actions workflow [SEC-1714] Mar 24, 2026
@spencerdrak spencerdrak marked this pull request as ready for review March 24, 2026 14:48
@spencerdrak spencerdrak merged commit cde6403 into develop Mar 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant