Interview Prep/GitHub Actions/OIDC & Security Hardening

What is script injection, and how do you fix it?

AdvancedConceptOIDC & Security Hardening
Answer

Interpolating attacker-controlled context into run: lets them inject shell commands, because ${{ }} is substituted into the script text.

# Vulnerable
- run: echo "Title: ${{ github.event.pull_request.title }}"
# Fixed
- env:
    TITLE: ${{ github.event.pull_request.title }}
  run: echo "Title: $TITLE"

Untrusted fields include PR and issue titles and bodies, comment bodies, branch names (head_ref), commit messages, author names and emails, and labels. The same applies to actions/github-script script: blocks. Linters like actionlint and zizmor flag these patterns.

All GitHub Actions questions Roadmap: GitHub Actions

More on OIDC & Security Hardening