A developer pushed directly to main and it went to production without review. How do you stop that?
BeginnerScenarioSecurity incidents
Answer
Situation read → The process allowed it, so fix the guardrail. Talk to the developer, but don't blame them.
What I'd do →
- Turn on a branch ruleset (or branch protection) for
main: require a PR, at least one approval, passing status checks, and no bypass for admins.
gh api -X PUT repos/acme/api/branches/main/protection --input protection.json
- Add CODEOWNERS so changes to sensitive paths (infra, pipelines) need the right team's review.
- Make the deploy job only run from merged PRs, and put production behind a protected environment.
- Apply it org-wide with rulesets so new repos are covered automatically.
- Review the change that went out, and revert it if needed.
Why → Organisation rulesets make the safe path the default for every repo.
Interview tip → Mention "include administrators"; protection that admins can bypass is often how this happens.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner