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 →

  1. 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
  1. Detach it from the ASG and load balancer (with --should-decrement-desired-capacity off) so it isn't replaced and terminated before forensics.
  2. Snapshot its EBS volumes and capture memory if you have the tooling.
  3. 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.
  4. 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.

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents