Scoping, containment & eradication
Scope an incident and choose containment that stops harm without destroying evidence.
By Invicly Tech, , in Cyber Security Fundamentals. About 11 minutes to read.
In short
Scoping finds every affected host and account before you act. Short-term containment stops immediate harm; long-term containment holds the line while you prepare a clean recovery. Eradication removes persistence and resets compromised credentials.
Explained simply
When an incident is confirmed, the urge is to fix the first infected machine right away. Experienced responders pause and ask: how far has this spread? That question is called scoping. Cleaning one laptop while the attacker sits on five more only warns them.
Containment means stopping the damage from growing. Short-term containment is the quick move, like cutting a laptop off the network or disabling a stolen account. Long-term containment holds the line for days, like extra firewall rules, while you prepare a clean fix.
Eradication means removing the attacker completely: their malware, their hidden ways back in (called persistence) and any passwords or keys they may have stolen. If you skip the passwords, they simply log back in.
Before calling it done, verify. Search again for every sign of the attacker, watch closely for a while, and only then return systems to normal work. That final step is recovery.
Press Play on a diagram to walk through it one step at a time.
- Step 1Scope
Find all affected systems.
- Step 2Contain
Isolate to stop harm.
- Step 3Eradicate
Remove persistence, reset creds.
- Step 4Verify
Confirm the threat is gone.
- Windows
- Run and RunOnce keys
- Scheduled tasks
- Services
- WMI subscriptions
- Startup folder
- Linux
- cron jobs
- systemd units and timers
- authorized_keys
- Shell start-up files
- Extra UID 0 users
- Identity
- New accounts
- New MFA devices
- Added group memberships
- Cloud and SaaS
- New access keys
- OAuth app consents
- Mailbox forwarding rules
In depth
Scoping: pivot until nothing new appears
Scoping starts with what you already know: a host, a user, a file hash, an IP or domain, a technique. Search for each of these everywhere: EDR, SIEM, DNS, proxy, email and cloud logs. Each hit can give you new indicators, such as another account the attacker used or another host that talked to the same server. Add those to the list and search again. Stop when a full round finds nothing new.
Keep a scope table with every affected host, account and indicator, plus its status: suspected, confirmed, contained, cleaned. Do not forget identity. Any account that logged on to a compromised host while the attacker was there may have had its credentials stolen, so it belongs in scope even if it shows no odd activity yet.
- 1Known indicators
Hosts, users, hashes, IPs, domains
- 2Search everywhere
EDR, SIEM, DNS, proxy, cloud
- 3New findings
More hosts or accounts involved
- 4Extract indicators
Add them to the scope table
- Back to step 1
Short-term vs long-term containment
Short-term containment buys time. Typical actions: isolate a host with the EDR agent, disable an account and revoke its sessions, block a domain or IP at DNS, proxy and firewall, and pull a malicious email from all mailboxes. Long-term containment keeps the attacker boxed in while you plan a clean rebuild: temporary firewall rules between network segments, moving a critical service to a clean server, patching the exploited flaw, and extra monitoring.
Three trade-offs shape every choice. Business impact: isolating the payment server stops sales, so leaders may need to decide. Evidence: isolate rather than power off, because shutting down destroys memory. Tipping off: a hands-on attacker who sees one door close may use another or turn destructive. When they are active on many systems, plan the actions and execute them all at the same agreed time.
- Isolate host with EDR
- Disable account, revoke sessions
- Block IP or domain
- Purge malicious email
- Temporary segment firewall rules
- Move services to clean systems
- Patch the exploited flaw
- Extra monitoring for weeks
Finding and removing persistence
Persistence is anything that brings the attacker back after a reboot or a password change. On Windows, look at Run and RunOnce registry keys, scheduled tasks, services, WMI event subscriptions, the Startup folder and new local admin accounts. On Linux, check cron jobs, systemd services and timers, authorized_keys files, shell start-up files such as .bashrc, and any user besides root with UID 0. In cloud and SaaS, look for new IAM users and access keys, OAuth apps granted access, new MFA devices and mailbox forwarding rules.
Tools such as Sysinternals Autoruns list Windows start-up locations in one place, and EDR can sweep all hosts at once. If an attacker had admin rights, rebuilding from a known-good image is usually safer than cleaning, because you can never be sure you found every change.
- autorunsc -accepteula -a * -c -h -s -m > autoruns.csv
- schtasks /query /fo LIST /v
- reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
- systemctl list-timers --all
Credential resets done right
Reset every credential the attacker used or could have stolen: accounts they logged in with, accounts that logged on to compromised hosts, service accounts, API keys, SSH keys and cloud access keys. A password reset alone may not end existing sessions, so also revoke sessions and refresh tokens in your identity provider.
Timing matters. If you reset passwords while a keylogger or backdoor is still running, the attacker simply captures the new ones. Remove persistence and block their infrastructure first, then reset, ideally all in one planned window. If the whole Active Directory domain was compromised, reset the krbtgt account password twice, waiting for replication and at least the maximum ticket lifetime (10 hours by default) between resets, so forged Kerberos tickets stop working.
- 1Remove persistence
Tasks, services, keys, rules
- 2Block infrastructure
Attacker IPs and domains
- 3Reset secrets
Passwords, API and SSH keys
- 4Revoke sessions
Tokens and refresh tokens
- 5Watch for reuse
Alert on old creds and IPs
Verifying eradication before recovery
Do not trust a single clean scan. Sweep every host again for all known indicators with your EDR, and with YARA rules if you have them. Check DNS, proxy and network logs for any further contact with attacker infrastructure. Check identity logs for logons from attacker IPs or with reset accounts. Confirm the original entry point is closed, for example the vulnerability is patched or the exposed service removed.
Restore only from backups taken before the earliest known attacker activity, and scan them before use. Bring systems back in stages, less critical ones first, and keep heightened monitoring with extra alerts for the known indicators for several weeks. If the attacker comes back, it is far better to see it on day two of recovery than on day ninety.
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Scope affected hosts and accounts~45m
- 2Compare short and long-term containment~45m
- 3Remove persistence and reset credentials~45m
- 4Verify eradication before recovery~45m
Key points
- Scope fully before containing to avoid missing hosts.
- Short-term containment stops immediate harm.
- Eradication removes persistence and resets credentials.
- Verify eradication before moving to recovery.
Key terms
Tap a card to flip it. 0/4 known
Examples
Scoping a stolen VPN account
Alert: user k.ito logged into the VPN from an unknown country at 01:30 UTC. Step 1: search VPN logs for the attacker IP: it also logged in as a second user, m.lee. Both accounts go into scope. Step 2: search for internal hosts reached from the VPN addresses given to those sessions: two file servers and one workstation. Step 3: EDR on the workstation shows a remote access tool installed at 01:52; its hash appears nowhere else. Step 4: DNS logs show the tool's domain queried only from that workstation. Step 5: another loop finds nothing new. Containment, all at 09:00: isolate the workstation, disable both accounts and revoke sessions, block the IP and domain, then reset passwords and enforce MFA on the VPN.
Hunting for persistence on a Linux server
A web server was compromised. Before deciding between cleaning and rebuilding, you check the usual hiding places. Step 1: users with UID 0 other than root. Step 2: every user's crontab and the system cron folders. Step 3: enabled services and timers, plus unit files changed in the last 30 days. Step 4: all authorized_keys files and their owners. Anything unexpected goes in the scope table with its hash and timestamps before you remove it.
awk -F: '$3 == 0 {print $1}' /etc/passwd
for u in $(cut -d: -f1 /etc/passwd); do
sudo crontab -l -u "$u" 2>/dev/null | sed "s/^/$u: /"
done
ls -la /etc/crontab /etc/cron.*
systemctl list-unit-files --state=enabled
systemctl list-timers --all
sudo find /etc/systemd /usr/lib/systemd -name "*.service" -mtime -30
sudo find / -xdev -name authorized_keys -exec ls -l {} \; 2>/dev/nullQuick reference
- Scope first: hosts, accounts and indicators; repeat searches until nothing new appears
- Isolate with EDR instead of powering off, so memory evidence survives
- Disable the account AND revoke its sessions and refresh tokens
- Against an active attacker, act on all known footholds at the same time
- Windows persistence: Run keys, scheduled tasks, services, WMI subscriptions, Startup folder
- Linux persistence: cron, systemd units and timers, authorized_keys, shell files, UID 0 users
- Domain compromise: reset krbtgt twice, at least 10 hours (default ticket lifetime) apart
- Restore only from backups taken before the earliest known attacker activity
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List the short-term containment actions for: (a) a stolen user account, (b) a laptop running malware, (c) a phishing email delivered to 200 inboxes.
- Exercise 2medium
Write PowerShell commands to check a Windows host for common persistence: non-Microsoft scheduled tasks, Run keys, services outside System32, WMI event consumers and local admins.
- Exercise 3hard
An attacker controls 3 workstations, 2 user accounts and 1 service account, and has a scheduled task on each workstation. Write a coordinated eradication plan in order, with timing.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Should I unplug or shut down an infected computer?
- Usually isolate it from the network with EDR or by disconnecting the cable, but leave it powered on so memory evidence survives. Shutting down is a last resort, for example if ransomware is actively encrypting shared drives and you cannot isolate it any other way.
- Is it better to clean or rebuild a compromised system?
- If the attacker had admin or root rights, rebuild from a known-good image and restore clean data. Cleaning is only reasonable for limited, well-understood infections.
- How do I know the attacker is really gone?
- You never know for certain, but you gain confidence by sweeping all hosts for known indicators, confirming no further contact with attacker infrastructure, closing the entry point and watching closely for several weeks.
- What is the difference between containment and eradication?
- Containment stops the damage from spreading, for example by isolating a host. Eradication removes the attacker's tools, persistence and stolen credentials so they cannot come back.