An EC2 instance is confirmed compromised. A colleague wants to terminate it immediately. What do you do instead?
IntermediateScenarioIncident Response and Governance
Answer
Situation read → Terminating destroys memory and disk evidence. We need to contain without losing forensics.
What I'd do →
- Isolate: replace its security groups with an empty "quarantine" group and detach it from the load balancer and Auto Scaling group.
aws autoscaling detach-instances --instance-ids i-0abc --auto-scaling-group-name web --should-decrement-desired-capacity aws ec2 modify-instance-attribute --instance-id i-0abc --groups sg-0quarantine - Enable termination protection and tag it
incident=IR-2026-014. - Capture memory (if tooling is available, e.g. AVML) and snapshot all EBS volumes.
- Detach or revoke the instance profile credentials (revoke older sessions on the role).
- Analyse snapshots in a separate forensics account, never on the live host.
Why → Evidence tells us how they got in and what they touched; without it we cannot be sure the fix is complete.
Interview tip → Note that changing security groups does not cut already-tracked connections; NACLs do.
More on Incident Response and Governance
You find a ransom note in an S3 bucket and most objects have been deleted. What do you do in the first hour?AdvancedYour company has its first real security incident and people are all talking at once in Slack. How do you organise the response?BeginnerFalco reports a reverse shell from a pod in EKS. How do you contain it while keeping evidence?AdvancedAfter a security incident, leadership wants to know who to blame. How do you run the post-incident review?BeginnerYou are asked to run a security tabletop exercise for the engineering team. How do you design it?IntermediateA developer's GitHub account was compromised and the attacker pushed a commit to `main` that adds a postinstall script. What now?Advanced