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?

AdvancedScenarioSecurity incidents
Answer

Situation read → Assume it's already been used; bots scrape GitHub within minutes. Contain first, investigate second, and deleting the commit is not containment.

What I'd do →

  1. Deactivate the key immediately (don't delete yet; you want it for the investigation).
aws iam update-access-key --user-name ci-deployer --access-key-id AKIA... --status Inactive
  1. Revoke anything the key could have created: check for new IAM users, keys, roles or policies, and attach a deny-all policy to the user.
  2. Investigate in CloudTrail by access key ID, across all regions (attackers launch miners in regions you don't use).
aws cloudtrail lookup-events --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIA... \
  --max-results 50 --region us-east-1
  1. Terminate unknown resources (EC2, Lambda, IAM entities), and check GuardDuty findings.
  2. Rotate: issue a replacement credential, better a role via OIDC, and update consumers.
  3. Clean Git history and contact AWS Support if the account was abused (they often waive fraudulent charges).

Why → Deactivation stops further use instantly; CloudTrail tells you what was already done.

Interview tip → Say "check all regions"; attackers deliberately use regions you don't watch.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents