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 →
- 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
- 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.
- 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
- Terminate unknown resources (EC2, Lambda, IAM entities), and check GuardDuty findings.
- Rotate: issue a replacement credential, better a role via OIDC, and update consumers.
- 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.
More on Security incidents
You 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?BeginnerA secret was printed in plain text in a CI job log. What do you do?Beginner