Containment, Eradication and Recovery

5 minutes 5 Questions

Containment, Eradication and Recovery are the core response phases of the NIST incident response lifecycle. AWS adopts this lifecycle in its Security Incident Response Guide, and SCS-C03 Domain 2 tests these phases heavily. CONTAINMENT limits the blast radius while preserving evidence. - EC2: Isolate the instance by replacing its security groups with a restrictive "isolation" group that has no inbound or outbound rules. Existing tracked connections may persist, so add network ACL deny rules for full isolation. Detach the instance from Auto Scaling groups, deregister it from load balancers, and enable termination protection. Capture EBS snapshots and volatile memory before making further changes. - IAM: Deactivate compromised access keys and attach an explicit deny policy such as AWSDenyAll. Use "Revoke active sessions" on the role, which adds a deny condition based on aws:TokenIssueTime. Apply SCPs for organization-wide restrictions. - S3: Tighten bucket policies and enable Block Public Access. - Automation: EventBridge rules triggered by GuardDuty or Security Hub findings can invoke Lambda or Step Functions for fast, consistent containment. ERADICATION removes the root cause and attacker artifacts. - Analyze evidence in an isolated forensic account using CloudTrail, VPC Flow Logs, Amazon Detective, and Athena queries. - Delete unauthorized IAM users, roles, and policies. Remove malicious Lambda functions, rogue instances, and backdoor resources, checking all Regions. - Rotate secrets with Secrets Manager and replace exposed credentials and KMS keys. - Patch vulnerabilities through Systems Manager Patch Manager, then validate remediation with Amazon Inspector. RECOVERY restores normal operations safely. - Rebuild workloads from known-good, hardened AMIs or infrastructure as code such as CloudFormation, rather than cleaning compromised hosts. - Restore data from AWS Backup or versioned S3 objects and verify its integrity. - Monitor closely with GuardDuty, CloudWatch, and AWS Config rules to detect reinfection. - Return traffic gradually as confidence grows. Exam tips: - Favor automated, scalable responses. - Preserve forensic evidence before terminating resources. - Use dedicated forensic accounts. - Prefer replacement over repair, in line with immutable infrastructure principles. - Feed post-incident lessons learned back into the preparation phase.

Containment, Eradication and Recovery in AWS Incident Response: A Complete Guide for the AWS Certified Security Specialty Exam

Introduction
Containment, Eradication and Recovery is the phase of incident response where defenders stop a threat from spreading, remove it from the environment and restore normal operations. In the AWS Certified Security - Specialty exam, this topic sits in the Threat Detection and Incident Response domain. It appears in scenario questions that ask which action to take first, which AWS service or feature fits best, or how to automate a response safely.

Why It Is Important
Detection alone does not protect an organization. A GuardDuty finding that reports a compromised EC2 instance or leaked access keys only has value if someone acts on it quickly and correctly. Getting this phase right matters for several reasons:
• Limit the blast radius: Fast containment stops attackers from moving laterally, escalating privileges, exfiltrating data or running up costs, for example through crypto-mining.
• Preserve evidence: Poorly planned actions, such as terminating an instance too early, can destroy volatile memory and disk evidence needed for forensics, legal action and root cause analysis.
• Prevent re-infection: If eradication is incomplete, attackers often return through backdoors they left behind. These include new IAM users, extra access keys, malicious Lambda functions or EventBridge rules.
• Restore business operations: Recovery returns systems to a known-good state with as little downtime as possible.
• Compliance and accountability: Many frameworks (PCI DSS, HIPAA, ISO 27001) require documented and repeatable incident response procedures.

What It Is
The phase comes from the NIST SP 800-61 incident response lifecycle, which AWS also uses in its AWS Security Incident Response Guide. The lifecycle has four phases:
1. Preparation
2. Detection and Analysis
3. Containment, Eradication and Recovery
4. Post-Incident Activity (lessons learned)

Each part of the third phase has its own goal:
• Containment: Isolate affected resources so the threat cannot spread or continue doing harm, while keeping evidence intact.
• Eradication: Remove the root cause and every artifact of the attacker. This covers malware, unauthorized credentials, persistence mechanisms and exploited vulnerabilities.
• Recovery: Bring systems back to normal operation from trusted sources, confirm they are clean and watch closely for signs of the attacker returning.

AWS groups containment strategies into three categories:
• Source containment: Filter or block the source of the attack, for example with NACL deny rules, AWS WAF IP sets or AWS Network Firewall rules.
• Technique and access containment: Stop the attacker from using the compromised mechanism, for example by deactivating access keys, revoking sessions or applying deny policies.
• Destination containment: Isolate the targeted resource, for example by moving an EC2 instance into an isolation security group.

How It Works: Containment on AWS

1. Compromised EC2 Instance
A typical, exam-relevant sequence:
• Capture metadata and tag the instance, for example Status=Quarantine, so the team and automation know it is under investigation.
• Enable termination protection so no one deletes evidence by accident.
• Detach the instance from its Auto Scaling group. Otherwise, health checks may terminate and replace it. Also deregister it from Elastic Load Balancers so it stops serving traffic.
• Isolate it at the network level. Replace its security groups with an isolation security group that has no inbound rules and no outbound rules, or only rules that allow access from a specific forensic workstation.
• Understand connection tracking: Security groups are stateful. Changing a security group does not always end existing tracked connections. Tracked connections can continue until they time out. To cut active sessions at once, use a network ACL deny rule, because NACLs are stateless. Another option is to first apply a security group that allows 0.0.0.0/0 for all traffic, which makes connections untracked, and then switch to the restrictive isolation group.
• Capture evidence: Take EBS snapshots of all volumes and capture memory using tools run through AWS Systems Manager Run Command before shutting anything down.
• Remove or replace the instance profile if the role credentials may be abused. Then revoke active role sessions, because credentials already issued stay valid until they expire.

2. Compromised IAM Credentials
• Access keys: Deactivate the exposed access key (set it to Inactive) rather than deleting it at first, so you keep the evidence trail. Create new keys for legitimate use, and delete the old key once the investigation finishes.
• Deny everything: Attach an explicit deny-all policy, such as the AWS managed policy AWSDenyAll, to the compromised user or role. An explicit deny always overrides any allow.
• Revoke temporary credentials: For IAM roles, use the console option Revoke active sessions. It attaches an inline policy (AWSRevokeOlderSessions) that denies all actions when aws:TokenIssueTime is earlier than the revocation time. This invalidates STS tokens that have already been issued.
• Console passwords: Reset passwords and enforce MFA.
• Root user compromise: Change the root password, rotate or remove root access keys, re-establish MFA and review the account contact details.
• Organization-wide containment: Apply a Service Control Policy (SCP) to restrict actions in a compromised member account or to block specific regions or services.

3. Other Resource Types
• Amazon S3: Turn on S3 Block Public Access, change bucket policies to deny unwanted principals, and review ACLs, access points and replication settings.
• AWS Lambda: Set reserved concurrency to 0 to throttle a malicious or compromised function, then review its code, layers, triggers and execution role.
• Amazon EKS and ECS: Cordon the affected node, isolate the pod with a Kubernetes network policy, label the pod for investigation and revoke the IAM credentials linked to the pod or node.
• Amazon RDS: Change the database security groups, rotate the master credentials (for example through Secrets Manager) and take a snapshot for forensics.
• AWS KMS: Disable a key or tighten the key policy if a key is being misused. Keep in mind that disabling a key affects every workload that depends on it.
• Network edge: Block malicious IPs with AWS WAF IP sets, AWS Network Firewall rules, Route 53 Resolver DNS Firewall (for malicious domains) or NACL deny rules.

How It Works: Eradication on AWS
• Find every persistence mechanism: Use AWS CloudTrail, Amazon Detective and CloudTrail Lake or Amazon Athena queries to find what the attacker created. Common examples include new IAM users, roles, access keys, login profiles, identity providers, cross-account trust policies, Lambda functions, EventBridge rules, EC2 instances in unused regions, AMIs, snapshots shared externally and changed resource policies.
• Remove the attacker's artifacts: Delete unauthorized resources and credentials once you have preserved the evidence.
• Fix the root cause: Patch the exploited vulnerability with Systems Manager Patch Manager, fix misconfigurations flagged by AWS Config or Security Hub, and tighten least privilege with IAM Access Analyzer.
• Rotate secrets: Rotate passwords, API keys and database credentials using AWS Secrets Manager. Treat any secret the compromised workload could reach as exposed.
• Scan for malware and vulnerabilities: Use GuardDuty Malware Protection for EBS volumes and S3, and Amazon Inspector for EC2, ECR images and Lambda.
• Prefer rebuilding over cleaning: In the cloud, the best practice is to replace compromised resources rather than try to clean them. Redeploy from a trusted, hardened golden AMI or container image using infrastructure as code.

How It Works: Recovery on AWS
• Restore from known-good sources: Use AWS Backup, EBS snapshots, RDS point-in-time recovery or S3 Versioning to restore data taken before the compromise. AWS Backup Vault Lock and S3 Object Lock protect backups from attackers, including ransomware.
• Redeploy with infrastructure as code: AWS CloudFormation or the CDK give consistent, auditable and clean rebuilds.
• Validate before reconnecting: Scan restored workloads, confirm configuration compliance with AWS Config rules and test functions before returning them to production.
• Return in stages: Shift traffic back gradually, for example with weighted Route 53 records or blue/green deployments.
• Increase monitoring: Watch closely with GuardDuty, CloudWatch alarms, VPC Flow Logs and Security Hub for indicators that the attacker is back.
• Disaster recovery: AWS Elastic Disaster Recovery can restore whole servers to a clean point in time.

Automation and Orchestration
AWS strongly encourages automated response to shorten response times:
• Amazon EventBridge rules match GuardDuty, Security Hub, Macie or Config findings and trigger targets.
• AWS Lambda or AWS Step Functions run containment workflows, such as isolating an instance or deactivating a key.
• Systems Manager Automation runbooks run predefined response steps, such as AWS-provided runbooks for isolating instances or disabling keys.
• Security Hub custom actions let analysts start a response workflow from the console with one click.
• AWS Systems Manager Incident Manager handles response plans, escalation, engagement of on-call staff and runbooks.
• AWS Config remediation actions automatically fix non-compliant resources, such as public S3 buckets.

Forensics Best Practices
• Use a dedicated forensics account in AWS Organizations with an isolated forensic VPC.
• Share or copy EBS snapshots to the forensics account. If they are encrypted with a customer managed KMS key, grant the forensic account access to that key. Snapshots encrypted with the AWS managed key cannot be shared, so re-encrypt them with a customer managed key first.
• Keep evidence integrity with checksums, S3 Object Lock and restricted access.
• Make sure CloudTrail logs are centralized, protected with log file validation and stored in a separate logging account.

Exam Tips: Answering Questions on Containment, Eradication and Recovery
1. Preserve evidence before you destroy anything. If an answer terminates a compromised instance or deletes resources right away, it is usually wrong. Prefer snapshots, memory capture, tagging and isolation first.
2. Know the correct order for EC2 incidents: tag and enable termination protection, detach from the ASG and deregister from the ELB, isolate with a restrictive security group, snapshot EBS and capture memory, then investigate in a forensic environment.
3. Watch for the words 'active connections' or 'existing sessions'. Security group changes may not stop tracked connections. A NACL deny rule is the answer when traffic must stop at once.
4. Leaked access keys: The best first step is usually to deactivate the key (or attach an explicit deny), then rotate, review CloudTrail for what the key did and remove unauthorized resources.
5. Compromised role credentials: Remember that STS tokens stay valid until they expire. Look for Revoke active sessions or a deny policy using aws:TokenIssueTime. Rotating keys or changing the role trust policy alone does not invalidate tokens already issued.
6. Prefer automation for speed and scale. When a question asks for the fastest, most scalable or least operational overhead response, choose GuardDuty, EventBridge and Lambda or SSM Automation, rather than manual steps or custom polling scripts.
7. Pick the least disruptive effective option. For example, isolating one instance is better than shutting down a whole VPC, and setting Lambda reserved concurrency to 0 is better than deleting the function.
8. Multi-account scenarios: SCPs, a centralized security tooling account, delegated administrator for GuardDuty and Security Hub, and a separate forensics account are common correct answers.
9. Eradication means hunting for persistence. Answers that only remove the obvious malware but skip checking for new IAM users, keys, roles, Lambda functions or resources in other regions are incomplete.
10. Recovery means rebuilding from trusted sources. Favor golden AMIs, infrastructure as code and immutable backups (Backup Vault Lock, S3 Object Lock) over patching a compromised host in place.
11. Know which service does what: GuardDuty detects, Detective investigates relationships and timelines, Security Hub aggregates and triggers custom actions, Inspector finds vulnerabilities, Macie finds sensitive data, Config tracks configuration and remediates, CloudTrail records API activity, and Incident Manager coordinates people and runbooks.
12. Encrypted snapshot sharing: If evidence must move to a forensic account, remember the customer managed KMS key requirement.
13. Root account compromise: Look for changing the password, enabling MFA, deleting root access keys and reviewing CloudTrail, often alongside contacting AWS Support.
14. Watch for distractors: Answers that rely on rebooting an instance (which loses memory evidence), deleting CloudTrail trails, or opening wider network access for investigators are almost always wrong.
15. Read the qualifier closely: Words such as first, most secure, least effort, preserve evidence and minimize downtime decide which otherwise valid answer is the best one.

Summary
Containment stops the damage while keeping evidence intact. Eradication removes the attacker and the root cause. Recovery restores trusted, monitored operations. On AWS, these steps rely on security groups and NACLs, IAM deny policies and session revocation, SCPs, snapshots, forensic accounts, and automated workflows built on GuardDuty, EventBridge, Lambda and Systems Manager. For the exam, think in order: preserve, isolate, investigate, eradicate, rebuild, monitor. Prefer automated, least-disruptive and evidence-preserving actions.
Test mode:
More Containment, Eradication and Recovery questions
26 questions (total)