Containing an intrusion before you know its scope often just teaches the attacker which foothold you found, while they keep the others. Responders face the same decision in almost every serious incident: act now to limit damage, or observe a little longer to find every account, host and persistence mechanism, then remove them all at once. This guide covers how to scope an incident, choose a containment strategy against explicit criteria, decide between immediate containment and coordinated eviction, and apply containment across identity, endpoint, network, cloud and SaaS layers. It is written for incident commanders, IR leads and SOC managers who already run a basic incident process and want to make better containment calls. For the overall response lifecycle see the Incident Response Guide.
Key takeaways
- Scope drives containment. NIST SP 800-61 Rev. 3 asks responders to estimate and validate an incident's magnitude (RS.AN-08) and to identify all affected hosts and services before eradication.
- Use written criteria, not instinct. Potential damage, evidence needs, service availability, effort, effectiveness and duration should decide each containment action, and the decision should be logged.
- Active, capable attackers need coordinated eviction. Removing access piece by piece lets them react; plan, then remove every known foothold in one window.
- Destructive or fast-moving attacks reverse the logic. Ransomware staging, data theft in progress or safety risk justify immediate containment even with incomplete scope.
- Identity is the hardest layer to contain. Password resets do not end existing sessions, and patching does not invalidate stolen tokens: plan session and token revocation explicitly, including for non-human identities.
Scoping: what you need to know before you act
Scoping answers how far the attacker got and what they can still reach. It runs continuously from detection to closure, but there is a minimum picture you need before deciding on containment. NCSC frames the first analysis priority as understanding enough to take containment actions, not everything.
| Scope dimension | Questions | Typical evidence |
|---|---|---|
| Identities | Which human, service and workload accounts did the attacker use, create or modify? Which tokens, keys or OAuth grants could they hold? | IdP sign-in and audit logs, directory change logs, app registration and service principal changes (ATT&CK T1098.001), key last-used data |
| Hosts and workloads | Which systems show attacker activity or tooling? Which were reachable with stolen credentials? | EDR telemetry, logon events, lateral movement indicators, cloud instance metadata |
| Persistence | What would let them back in after a reset? Web shells (T1505.003), scheduled tasks (T1053.005), services (T1543.003), new accounts (T1136), federation or authentication changes (T1556.007, T1484) | Autoruns, EDR persistence views, IdP federation settings, conditional access changes |
| Access paths | How did they get in, and is that path still open? VPN or remote services (T1133), exposed applications, third-party connections | Edge device logs, vulnerability status, supplier access records |
| Data | What was accessed, staged or exfiltrated? | File and mailbox audit, proxy and egress logs, cloud storage data events |
| Third parties | Are suppliers, customers or subsidiaries affected or the source? | Shared tenants, federation trusts, managed service provider access |
Track scope as a living list of indicators, accounts and assets with a confidence level for each. Use it to answer the incident commander's standing question: "If we act now, what will we miss?" For the forensic side of scoping see the Forensic Timeline Analysis Guide.
Choosing a containment strategy
AWS's incident response guidance restates the NIST criteria for selecting a containment approach. Score each candidate action against them and record the result in the decision log.
- Potential damage and theft: what will the attacker do if left in place for another hour, day or week?
- Evidence preservation: will this action destroy volatile evidence (memory, active connections) or tip off the attacker before collection?
- Service availability: what business service stops, and who must approve that?
- Time and resources: can the team execute it now, across all affected assets, and out of hours?
- Effectiveness: does it fully remove access or only part of it?
- Duration: emergency workaround, temporary measure or permanent fix? NIST SP 800-61 Rev. 3 asks teams to consider how long each containment measure will last.
AWS groups containment into three categories that work on any platform: source containment (filter or route to block access from a source), technique and access containment (remove the access the attacker uses) and destination containment (filter or route to protect the target). Good plans combine all three.
NIST SP 800-61 Rev. 3 recommends that handlers can select and perform containment manually, in addition to or instead of automated measures, and that teams consider automatic containment for some threats such as quarantining malware or moving an endpoint to an isolated remediation network. It also suggests authorising third parties such as ISPs and cloud providers to contain some incidents, for example large DDoS attacks, on the organisation's behalf.
Contain now or observe first
Observation is a deliberate, time-boxed decision taken by the incident commander with legal input, not a default. NIST notes that delaying containment, for example to redirect an attacker into a sandbox, can let them escalate access or compromise other systems, so the feasibility should be discussed with legal first. NCSC similarly advises considering whether the attacker may react to your actions, and that in some cases it is better to monitor and analyse further before acting.
| Situation | Default | Reason |
|---|---|---|
| Ransomware staging, mass deletion or encryption starting | Contain immediately | Damage is fast and irreversible |
| Active data exfiltration of regulated or sensitive data | Contain the channel immediately; widen scope in parallel | Each hour adds harm and notification scope |
| Safety or critical service risk (OT, health) | Contain immediately with operations | Human safety outranks evidence |
| Commodity malware on a single endpoint | Automated isolation and reimage | Low chance of a wider hands-on intrusion; check credentials used on the host |
| Hands-on intrusion, multiple footholds suspected, no imminent destruction | Observe briefly, scope, then coordinated eviction | Partial action alerts the attacker and leaves backdoors |
| Suspected state-sponsored espionage | Observe under strict time box, plan eviction, involve authorities | These actors maintain several access routes and react to partial clean-up |
| Stolen credential or token known to be in use | Revoke now, but scope what else it reached first if minutes allow | Bearer credentials give immediate access; revocation is cheap |
While observing, limit damage quietly: tighten egress monitoring, protect backups, raise alerting sensitivity on crown jewel systems and avoid actions an attacker would notice, such as resetting their accounts or sending mass password reset emails. Communicate on channels you are confident are not compromised.
Record the decision. Whichever way the call goes, log who decided, when, which criteria weighed most, what was accepted as residual risk, and when the decision will be reviewed. Observation decisions in particular are scrutinised afterwards by regulators, insurers and boards, and a clear record shows the delay was a risk-managed choice. See the Incident Log and Decision Record Template.
Coordinated eviction versus whack-a-mole
Whack-a-mole is removing each foothold as you find it. Against a capable attacker it usually fails: each removal shows them what you can see, and they use the access you have not found to re-establish themselves. Coordinated eviction removes every known foothold in one planned window. NCSC notes that remediation actions may be coordinated to run simultaneously.
- Pre-eviction: complete scoping to an agreed confidence level; build the eviction list (accounts, credentials, tokens, hosts, persistence, access paths, network indicators); prepare clean admin workstations and out-of-band communications; stage replacement credentials; confirm backups are clean; brief the business on downtime.
- Eviction window: execute all actions in a defined order within hours, for example block known infrastructure, cut external access paths, disable compromised and attacker-created accounts, revoke sessions and tokens, rotate credentials starting with the most privileged, remove persistence, isolate or rebuild affected hosts.
- Post-eviction: heightened monitoring for re-entry attempts, using the indicators you collected; verify each action took effect; keep the attacker's old access paths under watch as tripwires.
Order matters in identity. In Active Directory, compromise of the domain often requires resetting the krbtgt account password twice, with replication completing between resets, and rotating every privileged and service account password. In federated environments, Microsoft's guidance after golden SAML style attacks is to rotate the token-signing certificate twice, as the SolarWinds supply chain compromise showed (ATT&CK T1606.002). See the Active Directory Domain Compromise Playbook and the Identity Provider Tenant Compromise Playbook.
Containment options by layer
| Layer | Options | Watch out for | D3FEND |
|---|---|---|---|
| Identity (human) | Disable account, reset password, revoke refresh tokens and sessions, require re-registration of MFA methods | Existing access tokens and app session cookies outlive the reset | D3-AL Account Locking, D3-CR Credential Revocation, D3-ST Session Termination |
| Identity (non-human) | Rotate secrets and keys, remove added credentials from app registrations, revoke OAuth grants, disable service principals | Breaking production; unknown owners; credentials assumed unused | D3-CR Credential Revocation, D3-CE Credential Eviction |
| Endpoint | EDR network isolation, kill processes, quarantine files, reimage | Isolation before memory capture loses evidence | D3-NI Network Isolation, D3-PT Process Termination, D3-FEV File Eviction |
| Network | Block IPs and domains, sinkhole DNS, segment, disable VPN profiles, cut supplier links | Attackers rotate infrastructure; blocking one IP rarely holds | D3-NI Network Isolation |
| Cloud | Explicit deny policies on compromised roles, restrictive security groups, revoke role sessions, snapshot before changes | Terminating instances destroys evidence; other regions and accounts | D3-CR Credential Revocation |
| SaaS | Revoke sessions, disable connected apps and integrations, remove forwarding rules, lock external sharing | Integration tokens survive user resets | D3-ST Session Termination |
D3FEND groups these countermeasures under its Isolate and Evict tactics, which makes it a useful catalogue when building layer runbooks. See the MITRE D3FEND Guide.
Where identity fits
Identity containment fails quietly because tokens and sessions are independent of passwords. Microsoft documents that Entra ID access tokens last one hour by default and remain usable until they expire after refresh tokens are revoked, and that Entra ID cannot revoke application session cookies directly: the application has to end its own sessions, unless it supports Continuous Access Evaluation. In hybrid environments Microsoft recommends acting on on-premises Active Directory first, including resetting the password twice to mitigate pass-the-hash.
- Sessions survive patches: in CitrixBleed, patching stopped new session leakage but did not invalidate stolen cookies, so Citrix told customers to terminate all active and persistent sessions after upgrading. Treat stolen sessions (T1539) as credentials.
- Non-human credentials are part of scope: after the Okta support system breach, Cloudflare left one service token and three service accounts unrotated because it believed they were unused, and an attacker used them weeks later. See the Cloudflare Thanksgiving breach. Rotate every credential that was exposed, not just those you know are active.
- Dependencies: map which applications use each service account before rotating, or plan an outage. See the Leaked Credential Response Playbook.
Preparing containment before the incident
- Pre-approve actions. Define which containment actions the SOC may take without escalation (isolate a workstation, revoke a user's sessions) and which need the incident commander or service owner (isolate a server, disable a federation trust).
- Write layer runbooks. One page per platform: how to isolate, revoke, rotate and snapshot, with the role required. Keep copies offline.
- Prepare out-of-band capability. Communications outside the corporate tenant, clean admin workstations, and break-glass accounts not synchronised from the directory under attack.
- Inventory non-human identities with owners and dependencies. Without it, eviction either breaks production or leaves keys behind.
- Exercise the decision. Run a tabletop where the facilitator forces a contain-or-observe choice with incomplete scope, then a technical drill of a mass session revocation and service account rotation in a test tenant.
- Plan rollback. For each containment action document how to reverse it if it was wrong or caused unacceptable outage, and who decides.
Decision guidance by organisation size
- Small organisations: lean on automated EDR isolation and managed service or retainer support. Pre-agree with the provider what they may contain without asking. Prioritise revoking sessions and resetting cloud admin accounts, which give the most protection for the least effort.
- Mid-sized organisations: pre-approved action matrix, layer runbooks and at least one rehearsed eviction for an identity provider compromise.
- Large or regulated organisations: a standing eviction planning cell drawn from IAM, network, cloud and application teams; separate administrative infrastructure; legal and law enforcement engagement procedures; formal sign-off of eviction windows.
Measuring containment
- Time to contain: from incident declaration to the attacker's last confirmed activity, by severity.
- Re-compromise rate: incidents where attacker activity reappeared within 30 days of containment.
- Eviction completeness: percentage of eviction list items verified done within the window.
- Credential coverage: percentage of exposed credentials, including non-human ones, rotated or revoked within target.
- Containment-caused outage: unplanned downtime caused by containment actions, as a check on runbook quality.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | RS.AN-08, RS.MA-03, RS.MA-04, RS.MI-01, RS.MI-02, RS.MA-05 | Magnitude estimated, prioritised and escalated, contained, eradicated, recovery criteria applied |
| NIST SP 800-53 Rev. 5 | IR-4 Incident Handling, IR-8 Incident Response Plan | Containment as part of handling; strategy defined in the plan |
| ISO/IEC 27001:2022 | Annex A 5.26 Response to information security incidents | Documented response procedures |
| CIS Controls v8.1 | Control 17 Incident Response Management | Roles, procedures and exercises. See the CIS Control 17 Incident Response Management Guide |
| MITRE ATT&CK and D3FEND | Persistence techniques listed above; D3FEND evict and isolate techniques | Scope checklists and containment action catalogue |
Common failure patterns
- Resetting passwords and calling it contained: refresh tokens, app sessions, OAuth grants and API keys remain valid.
- Patching the entry point but not killing sessions: the CitrixBleed pattern, where access continued after the fix.
- Skipping "unused" credentials: the Cloudflare pattern, where four credentials assumed inactive gave a later attacker a way in.
- Tipping off the attacker: resetting one account they use, or discussing the incident in a mailbox they can read, before the eviction plan is ready.
- Isolating before collecting: pulling the network or rebooting before capturing memory and volatile state on key hosts.
- Observation without a deadline: "watch and learn" that drifts while data leaves; every observation period needs an end time and tripwires.
Lessons from incidents
- Cloudflare, November 2023: the attacker explored Confluence and Jira from 14 November using credentials left over from the Okta breach, and Cloudflare detected the activity on 23 November. Its response illustrates coordinated eviction at scale: a dedicated remediation effort that rotated more than 5,000 production credentials, triaged 4,893 systems and reimaged every machine in its global network. The lesson is that eviction scope must be set by what was exposed, not by what is believed to be in use.
- CitrixBleed, October 2023: organisations that patched promptly were still breached through cookies stolen before the patch. Containment for any edge device vulnerability that leaks memory or credentials must include ending sessions and rotating credentials that passed through the device, not just applying the fix.
- SolarWinds and golden SAML, 2020: attackers who can forge tokens or add credentials to trusted applications survive ordinary password resets. Eviction had to include the token-signing certificate and a review of credentials added to existing service principals, which few organisations monitored at the time.
Across all three, the common thread is that the containment plan treated credentials, sessions and trust relationships as part of the attack surface to be reset, and that the incomplete first attempts are what attackers exploited.
Practitioner checklist
- Maintain a pre-approved containment action matrix by asset type and severity.
- Keep layer runbooks for identity, endpoint, network, cloud and SaaS, with offline copies.
- Record every containment decision against the six criteria in the incident decision log.
- Set a time box and tripwires whenever the decision is to observe.
- Build an eviction list covering accounts, tokens, keys, persistence, access paths and infrastructure before acting on a hands-on intrusion.
- Revoke sessions and tokens explicitly, including for SaaS integrations and service principals.
- Rotate every exposed non-human credential, using an inventory with owners and dependencies.
- Capture volatile evidence on priority hosts before isolation where safety allows.
- Monitor for re-entry for at least 30 days after eviction and track re-compromise.
Standards and references
- NIST: SP 800-61 Rev. 3 Incident Response Recommendations and Considerations for Cybersecurity Risk Management
- NCSC: Cyber incident response processes
- AWS: Security Incident Response User Guide, Containment
- Microsoft Learn: Revoke user access in an emergency in Microsoft Entra ID
- MITRE D3FEND: Evict and Isolate techniques
- MITRE ATT&CK: Steal Web Session Cookie
- MITRE ATT&CK: Additional Cloud Credentials
Related NHI Mgmt Group resources: Incident Response Guide · Identity Incident Response Playbook · Ransomware Response and Recovery Guide · Incident Commander Role Guide