CloudTrail shows a new IAM role with AdministratorAccess was created in prod at 2 AM by a user nobody recognises. What do you do?
AdvancedScenarioSecurity incidents
Answer
Situation read → Probably persistence after a compromise: the attacker creates their own admin path so rotating the original key doesn't lock them out.
What I'd do →
- Contain the new role: attach an explicit deny-all inline policy (faster and safer than deleting, and it keeps evidence), and revoke its active sessions.
- Identify the creator from the CloudTrail event (
userIdentity, source IP, access key). Disable that principal. - Pull the full trail for that principal and the new role: other roles, users, keys, trust policies updated to trust external accounts, Lambda functions, new regions used.
aws cloudtrail lookup-events --lookup-attributes AttributeKey=Username,AttributeValue=svc-legacy \
--start-time 2026-11-08T00:00:00Z
- Remove every persistence mechanism you find, then rotate the credentials that led in.
- Prevent: SCPs limiting IAM changes in prod to the pipeline role, alerts (EventBridge) on
CreateRole,AttachRolePolicyandCreateAccessKeyin prod, and GuardDuty.
Why → Attackers create several backdoors; removing only one leaves them inside.
Interview tip → Look for trust policies pointing at external account IDs; it's a common hidden backdoor.
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