GuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?
AdvancedScenarioSecurity incidents
Answer
Situation read → Treat the instance as compromised. Isolate it, keep it for forensics, and find out what its role could reach.
What I'd do →
- Isolate the network: swap its security groups for an empty "quarantine" SG (no inbound, no outbound). Existing tracked connections may survive briefly, so also add a NACL deny if needed.
aws ec2 modify-instance-attribute --instance-id i-0abc --groups sg-0quarantine
- Detach it from the ASG and load balancer (with
--should-decrement-desired-capacityoff) so it isn't replaced and terminated before forensics. - Snapshot its EBS volumes and capture memory if you have the tooling.
- Check the instance role in CloudTrail: what API calls did it make? Its credentials may have been stolen via IMDS and used elsewhere; revoke active sessions for that role.
- Find the entry point (unpatched service, exposed port, stolen SSH key), fix it, and launch clean replacements from a known-good AMI.
Why → The instance role is the blast radius; stolen role credentials work from anywhere until they expire or are revoked.
Interview tip → Mention revoking role sessions (IAM "Revoke active sessions"), not just stopping the instance.
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?IntermediateYou 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