Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 37 ยท Incident Response

Containment, Eradication and Recovery

Learn how to stop an incident spreading, remove the attacker's foothold and safely restore systems, with decision criteria, checklists and a scoping exercise.

Once analysts confirm an incident, the pressure changes from "is it real?" to "how do we stop it without making things worse?". Three activities follow, in this order: containment limits the damage, eradication removes the attacker's access and tools, and recovery brings systems back to a trusted state. Rushing any of them can leave the attacker inside or erase your only copy of the evidence.

This lesson covers the decisions behind each step. It describes defensive actions on systems you are authorized to manage.

Scope first

Before you act, estimate how far the incident reaches. Acting on one machine while three others are compromised just alerts the attacker. Scoping answers:

  • Which accounts did the attacker use or create?
  • Which hosts did they touch, and how did they move between them?
  • Which data was accessed, copied or changed?
  • When did it start? (Often weeks before the first alert.)

Use the SIEM to pivot: take every indicator you have (account, IP, file hash, process name) and search for it across all log sources. The mini threat hunt project practices exactly this.

Containment

Containment comes in two flavors.

Short-term containment is quick and reversible: isolate a host with the EDR agent, disable or lock an account, revoke tokens and sessions, block an address or domain at the firewall or proxy, quarantine an email from all mailboxes.

Long-term containment keeps the business running while you prepare eradication: moving critical systems to a clean network segment, applying temporary access rules, or adding extra monitoring.

Choosing a strategy

Question If yes If no
Is data being stolen or encrypted right now? Contain immediately, accept some disruption You have time to scope before acting
Does the system support a critical service? Prefer targeted controls (block one account) Full isolation is fine
Do you need to watch the attacker to learn their goals? Contain quietly with legal and management agreement Contain now
Is evidence at risk from isolation? Capture memory first Isolate

Powering a machine off destroys volatile evidence such as running processes, network connections and keys held in memory. Prefer network isolation, and capture memory first when the incident justifies it. See evidence handling.

Eradication

Eradication removes everything that lets the attacker return:

  • Malware, web shells and scheduled tasks or services they installed (persistence).
  • Compromised and attacker-created accounts; reset credentials, including service accounts and API keys that the attacker could have read.
  • The vulnerability or misconfiguration they used, by patching or reconfiguring.
  • Malicious mailbox rules, OAuth app grants and similar cloud persistence.

A common error is to remove the one file you found and declare victory. Eradication should be driven by the full scope, and verified by searching again for every indicator afterwards.

Containment, eradication, recovery

Contain Stop the spread
Eradicate Remove access and tools
Recover Restore trusted service

Each step needs evidence from the one before.

1 / 2

Recovery

Recovery returns systems to normal operation in a trusted state:

  1. Rebuild from known-good images or install media rather than "cleaning" a compromised host. Cleaning is rarely certain.
  2. Restore data from a backup taken before the compromise, after checking the backup itself is clean.
  3. Apply patches and hardening before reconnecting.
  4. Bring systems back in priority order, starting with the most critical services.
  5. Monitor intensively for several weeks: extra alerts on the affected accounts and hosts, and repeated searches for the indicators.

Define clear exit criteria for recovery, such as "no indicator hits for 14 days and all affected credentials rotated".

Try it: scope an intrusion from indicators

This stand-in uses a few log lines and a growing set of indicators to find every host involved, the way analysts pivot in a SIEM. The data is invented.

Python Scoping by pivoting

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The loop stops at 10.0.0.9 on purpose: that address is a normal batch job that merely connected to the database, and the analyst decided it was not part of the intrusion. Real scoping needs that kind of judgement; automation only suggests candidates.

Try it: a recovery checklist

Python Recovery gate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Communication during recovery

Tell stakeholders what they need and no more: the business impact, what you are doing, when the next update comes. Route outside statements through the communications and legal contacts named in your IR plan. Keep an internal log of every action with the time and the person, because regulators and insurers may ask for it.

Common mistakes

  • Containing before scoping, so the attacker simply moves to another host.
  • Restoring a backup that already contains the attacker's persistence.
  • Resetting user passwords but forgetting service accounts, API keys and tokens.
  • Declaring "recovered" with no monitoring plan afterwards.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the difference between containment and eradication?

    Containment stops damage growing. Eradication removes the cause so the attacker cannot return.
  2. 2. Why is powering off a compromised host often a poor first move?

    Memory holds processes, connections and keys that disappear on shutdown. Network isolation preserves them.
  3. 3. Which recovery approach is generally most trustworthy?

    Cleaning a host cannot prove every backdoor is gone; a rebuild gives a known state.
  4. 4. Why scope an incident before containing it?

    A partial response teaches the attacker to hide or accelerate, and leaves footholds.

Summary

  • Scope first, then contain, eradicate and recover in that order.
  • Prefer reversible containment such as isolation and account disabling; avoid shutting down before capturing evidence.
  • Eradicate everything in scope and verify with fresh searches.
  • Recover from clean sources, reset all credentials and keep intensive monitoring with clear exit criteria.

Next: Evidence Handling and Forensic Basics