Goal. By the end you can handle five common incident types (ransomware, business email compromise and account takeover, a commodity malware outbreak, a web shell and exposed cloud keys) and explain the trade-off behind each decision.
Why it matters#
A generic list of steps hides the hard calls. Containing fast can destroy evidence. Rebuilding a machine can erase the proof of how the attacker got in. Resetting a password without ending the attacker's sessions leaves them logged in. Each scenario below is a set of costly decisions.
What you will learn#
Principles for every scenario#
- Contain, eradicate and recover are different jobs. Containment stops the spread and should be reversible. Eradication removes the attacker's access and must find the way in. Recovery restores service and must prove the result is clean.
- Preserve before you change, within reason. Capture the perishable evidence (memory, running processes, key logs) quickly, then act. Do not let a perfect image cost you the network. CISA's ransomware guide asks for an image and a memory capture from a sample of affected devices, and lists powering down as a last resort because it loses evidence held in memory.
- Contain in one move. Piecemeal containment tells the attacker, who may change tack. Plan, then isolate together, and talk out of band.
- Rebuild beats clean when trust is lost, but only once you know how they got in. Otherwise you rebuild into the same hole.
Ransomware#
Ransomware encrypts data and demands payment. Many crews steal data first and threaten to publish it, which CISA calls double extortion.
- First move. Find out how far it has spread and whether encryption is still running. Protect the backups: disconnect or lock them, and confirm you have an offline or immutable copy. Many strains hunt for backups to delete or encrypt.
- Preserve. Memory and an image from a sample of hosts, plus security and firewall logs.
- Contain. Isolate the affected machines together. If many are hit, taking the network offline at the switch may be the only workable step.
- Eradicate. Find the way in (remote access without MFA, a phished account, an unpatched edge device) and the persistence. Assume any password, key or token within the attacker's reach is now known to them. If domain administrator rights were exposed, plan a directory-wide reset.
- Recover. Rebuild from known-good images, restore from verified backups in priority order, check restored systems before reconnecting, then watch closely.
- Trade-offs. Powering off stops spread but loses memory. A free decryptor may exist. Paying is a decision for leadership and Legal, not the SOC: the US Treasury warns that payments can breach sanctions rules even when the payer did not know, and says prompt reporting and cooperation with law enforcement count in your favour. This is not legal advice.
- Easily missed. Data theft. Check what left the network before deciding it was only encryption, because notification clocks may apply (Stage 9).
Business email compromise and account takeover#
An attacker controls a mailbox or an identity, through a phished password or a stolen session, and uses it to read mail, hide messages and ask people to pay or change bank details.
- First move. Speed beats stealth, because money moves in hours. Tell finance to hold payments and bank-detail changes linked to the account. If money has moved, call the bank about a recall and report to law enforcement.
- Contain. Disable the account, then revoke its sessions and refresh tokens. A password reset alone does not end a session already open. Microsoft's guidance notes that access tokens last an hour by default, so ask your identity provider what revocation actually covers.
- Eradicate. Remove mailbox rules and forwarding, delegated access, app consents and MFA methods or devices the attacker added. Search sent items for fraud messages and find who else received the lure.
- Preserve. Export the audit and sign-in logs before retention windows delete them, and keep the original phishing email with its headers.
- Recover. Confirm who the person is by phone or face to face before re-enrolling MFA. Watch the account for a month.
- Trade-off. Warning the user by email warns the attacker too. Use the phone.
- Easily missed. Suppliers and colleagues who already received fraudulent requests from the account.
Commodity malware outbreak#
Information stealers and loaders spread through phishing, fake software downloads and removable media. "Commodity" does not mean harmless: a stealer takes saved passwords and session cookies, and a loader can bring whatever its operator sells next.
- First move. Work out the behaviour from your EDR (what runs, what it contacts, what it drops), then find every host showing it.
- Contain. Use EDR network isolation, which is reversible. Block the domains and hashes, which is cheap but weak, and hunt on behaviour across the fleet too.
- Eradicate. Reset passwords and revoke sessions for every user whose browser held credentials on an infected machine, since a password reset does not defeat a stolen cookie. Close the way in.
- Recover. Reimage if you see persistence, hands-on activity or anything you cannot vouch for. Clean in place only for a low-risk family with a vendor-verified removal.
- Trade-off. Reimaging destroys evidence and costs the user a day. Take a triage collection first (Stage 6).
- Easily missed. Credentials that live elsewhere: browser-synced accounts, code-hosting and cloud tokens.
Web shell#
A web shell is a small script on a web server that lets an attacker run commands through ordinary web requests.
- First move. Snapshot the server, or copy the web root and logs, before touching anything.
- Contain. Cut the server off from internal systems, since it often bridges inward. Decide with the owner whether to take the site down. A web application firewall rule is a stopgap, not a fix.
- Find. New or changed files in web-served folders, the web server process starting a shell, and odd requests (often POSTs) to unfamiliar files in the access logs. Then find the flaw they used.
- Eradicate. Copy the shell for analysis, then remove it. Fix the flaw. Rotate every secret on the server (database passwords, API keys, signing keys): patching does not evict someone who already holds them.
- Recover. Rebuild from known-good and redeploy code from source control.
- Trade-off. Taking the site down protects data and costs revenue. Decide fast, with the owner.
- Easily missed. More than one shell, movement to other systems, and the same flaw on sister servers.
Exposed cloud keys#
A long-lived access key lands in a public repository, a paste or a support ticket.
- First move. Identify the key and its owner, and read its activity in the cloud audit log across every region.
- Contain. Switch the key off before you remove it: switching off can be undone, and AWS's guidance is to delete the original only once you have confirmed your applications still work. Call the owner first, because production code may depend on it. Add a deny policy: AWS publishes a managed quarantine policy,
AWSCompromisedKeyQuarantineV3at the time of checking, that blocks actions attackers usually take next, such as creating users and keys, attaching policies and launching instances. Read it before relying on it. - Eradicate. Look for what the key created: users, keys, roles, changed trust policies, functions and instances, including in regions you never use. Remove them and rotate every secret the key could read. Temporary credentials issued earlier can outlive the key, so use your provider's session-revocation feature.
- Recover. Replace the key with a role or short-lived credentials. Treat the secret as burned even after you clean the repository history, because it has been copied.
- Trade-off. Deactivating at once may break an application. Waiting for the owner gives the attacker time. Decide per key; for a critical one, apply the deny policy and issue a replacement quickly.
- Easily missed. Billing alerts and resources in quiet regions.
aws iam get-access-key-last-used --access-key-id AKIAIOSFODNN7EXAMPLE
aws iam update-access-key --user-name example-user --access-key-id AKIAIOSFODNN7EXAMPLE --status InactiveDo this#
- Write a first-hour card for each scenario (2–3 hours). One page: first move, what to preserve, contain, eradicate and recover, who to call and what not to do.
- Decide when to watch (45 minutes). For each scenario, write the one condition under which you would watch the attacker briefly, who must approve and when it expires.
- Run the key drill (1–2 hours). In a throwaway cloud account with a billing alert, create a test user and key (never a real secret), use it, find the use in the audit log, deactivate it and clean up.
- Run the mailbox drill (1–2 hours). In a test tenant, give a test user an inbox rule and an app consent. Find and remove them, revoke the sessions, and list what you would preserve first.
Resources#
Free first
- #StopRansomware Guide - CISA's prevention and response checklists.
- NIST IR 8374 Rev. 1 - a ransomware risk management profile built on CSF 2.0.
- No More Ransom - free decryption tools and advice from law enforcement and industry.
- OFAC advisory on ransomware payments - the sanctions risk of paying, from September 2021 (US; not legal advice).
- Respond to a compromised email account and Revoke user access in an emergency - Microsoft's steps, useful even if you use another provider.
- Resolve issues with unauthorized activity in AWS accounts - AWS's own guidance on a compromised key or account.
- AWS customer playbook framework - sample playbook templates for AWS scenarios.
- Mitigating Web Shells - NSA's guidance on detecting and preventing them.
Paid or needs an account
- None needed. Use a free cloud account for the key drill, with a billing alert.
Checkpoint#
You are ready to move on when you can:
Go deeper (optional)#
- Read the ATT&CK pages for Data Encrypted for Impact (T1486), Inhibit System Recovery (T1490) and Web Shell (T1505.003), and note the detections each suggests.