Playbook Design: Scripting Containment Under Pressure
Why Playbooks Matter
During an active incident, responders are under extreme pressure. Decisions must be made in seconds, and the stakes are high — a wrong move can destroy evidence, spread the attack, or cause business disruption. Playbooks eliminate the need to make ad-hoc decisions by pre-scripting the containment steps for each incident type.
A playbook is not a narrative document — it is an executable procedure. Each step is a specific action with a clear expected outcome. The responder follows the playbook like a checklist, executing each step in order.
Playbook Structure
playbook:
name: "Ransomware Containment"
description: "Isolate affected hosts and block ransomware C2 to prevent spread"
triggers:
- alert.rule.category: "ransomware"
- alert.severity: "critical"
steps:
- step: 1
action: "isolate_host"
target: "{{alert.host.name}}"
method: "network_isolation"
expected_outcome: "Host has no network connectivity"
verification: "ping {{alert.host.ip}} — should timeout"
- step: 2
action: "block_c2"
target: "{{alert.network.dest_ip}}"
method: "firewall_block"
expected_outcome: "C2 IP blocked at perimeter firewall"
verification: "Check firewall rule exists"
- step: 3
action: "capture_memory"
target: "{{alert.host.name}}"
method: "memory_capture"
expected_outcome: "Memory dump saved to evidence share"
verification: "File exists and hash recorded"
- step: 4
action: "notify"
target: "soc_manager"
method: "email"
expected_outcome: "SOC manager notified of ransomware containment"
Design Principles
- Specific over general — "isolate host WS-042 from the network" not "isolate the affected systems"
- Verifiable — each step has a verification method so the responder knows it worked
- Ordered — steps are numbered and must be executed in sequence
- Conditional — include decision points: "if the host is a domain controller, skip step 1 and notify the IC first"
- Reversible — document how to undo each step if it was done in error
Incident-Type Playbooks
Ransomware Playbook
- Isolate affected hosts from the network (do NOT power off — preserve memory)
- Block ransomware C2 IPs at the firewall
- Identify the ransomware variant (check file extensions, ransom notes)
- Determine the initial attack vector (phishing? RDP? vulnerability?)
- Check for lateral movement — are other hosts encrypted?
- Capture memory from affected hosts
- Notify SOC manager and CISO
- Engage cyber insurance carrier
- Begin eradication planning (restore from backup vs. rebuild)
Data Exfiltration Playbook
- Block the destination IP/domain at the firewall and proxy
- Isolate the affected host from the network
- Identify what data was accessed (review file access logs, database query logs)
- Determine the exfiltration method (HTTP, DNS, cloud storage)
- Preserve evidence — memory capture, disk image
- Notify legal counsel — regulatory notification may be required
- Engage forensic team for detailed analysis
Phishing / Credential Compromise Playbook
- Identify all users who received the phishing email
- Delete the phishing email from all mailboxes
- Reset credentials for users who clicked the link or entered credentials
- Revoke active sessions and tokens for compromised accounts
- Check for mailbox rules created by the attacker (forwarding rules, hidden rules)
- Scan all endpoints for malware delivered via the phishing email
- Block the phishing URL at the proxy and DNS
Insider Threat Playbook
- Do not alert the suspect — covert monitoring only
- Preserve all evidence — do not tip off the suspect
- Coordinate with HR and legal before any action
- Monitor the suspect's network and file access activity
- Document all evidence for potential legal proceedings
- Plan the termination and access revocation for a coordinated moment
Isolation Techniques: Preserving Evidence While Stopping the Attack
The Isolation Decision: How to Stop the Attack Without Destroying Evidence
Containment requires stopping the attack from spreading. The method you choose determines whether you preserve forensic evidence or destroy it. The golden rule: isolate, do not power off.
Network Isolation
Network isolation disconnects the host from the network while keeping it running. This stops the attack from spreading to other systems and prevents C2 communication, but preserves memory, running processes, and disk state.
Windows (PowerShell)
# Disable all network adapters
Get-NetAdapter | Disable-NetAdapter -Confirm:$false
# Verify isolation
Test-NetConnection -ComputerName 10.0.0.1 -Count 1
# Should fail — host is isolated
Linux
# Disable all network interfaces
ip link set eth0 down
ip link set eth1 down
# Verify isolation
ping -c 1 10.0.0.1
# Should fail — host is isolated
Cloud (AWS)
# Modify the security group to deny all traffic
aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --groups sg-isolated
# Or move to an isolated security group
aws ec2 create-security-group --group-name "isolated" --description "Quarantine SG"
aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --groups sg-isolated-12345678
Why Not Power Off?
Powering off a host destroys the most valuable forensic evidence:
- Memory — all running processes, network connections, encryption keys, and injected code are lost
- Temporary files — swap files, temp directories, and cache are lost or corrupted
- Volatile registry keys — some registry hives are only in memory
The only exception: if the host is actively destroying evidence (e.g., a wiper malware is running) and you cannot isolate it fast enough, powering off may be the lesser evil. But this is a last resort.
Account Isolation
For credential compromise incidents, isolate the compromised account:
# Disable the account
Disable-ADAccount -Identity compromised_user
# Revoke all active sessions
# Azure AD
Revoke-AzureADUserAllRefreshToken -ObjectId (Get-AzureADUser -Filter "userPrincipalName eq 'user@domain.com'").ObjectId
# Office 365
Revoke-SPOUserSession -User "user@domain.com"
Account isolation stops the attacker from using the stolen credentials while preserving the account's audit logs and history for investigation.
Network-Level Isolation
For widespread incidents, isolate at the network level rather than per-host:
- VLAN isolation — move affected hosts to a quarantine VLAN with no routing to production
- Firewall rules — block traffic between network segments
- DNS sinkhole — redirect malicious domains to a sinkhole server
- BGP blackhole — null-route malicious IPs at the router level
# Cisco ASA: block a malicious IP
shun 185.220.101.4
# iptables: block outbound to a malicious IP
iptables -A OUTPUT -d 185.220.101.4 -j DROP
# Windows Firewall: block an IP
netsh advfirewall firewall add rule name="Block C2" dir=out action=block remoteip=185.220.101.4
Containment Verification
After isolation, verify that the containment worked:
- Network isolation — ping the host from another system; should timeout
- Account isolation — attempt to authenticate with the compromised account; should fail
- Firewall block — check that the firewall rule exists and is logging hits
- C2 communication — check firewall/proxy logs for connection attempts to the C2 IP (should show blocked attempts)
Verification is critical. A containment step that was not actually executed gives a false sense of security while the attack continues.
Credential Rotation and Post-Containment Actions
After Containment: Closing the Doors the Attacker Used
Containment stops the attack from spreading. But the attacker's initial access vector and any persistence mechanisms remain. Post-containment actions close these gaps to prevent re-compromise.
Credential Rotation
If the attacker obtained credentials — through phishing, credential dumping, or database theft — those credentials must be rotated. The rotation scope depends on what was compromised:
Single User Compromise
- Reset the user's password
- Revoke all active sessions and tokens
- Check for MFA bypass (did the attacker register a new MFA device?)
- Review the user's recent activity for unauthorized actions
Domain Admin or Service Account Compromise
- Reset the account password
- Reset the KRBTGT account password twice (to invalidate all Kerberos tickets)
- Revoke all Kerberos tickets
- Check for Golden Ticket attacks (unusual ticket lifetimes)
- Review all systems the account has accessed
Widespread Credential Compromise
If the attacker had access to a credential store (LSASS, NTDS.dit, cloud IAM), assume all credentials in that store are compromised:
- Reset all potentially affected passwords
- Rotate all API keys and service account credentials
- Revoke all active sessions across the environment
- Review authentication logs for unauthorized use of other credentials
# Reset KRBTGT password twice (Golden Ticket mitigation)
# First reset
Set-ADAccountPassword -Identity krbtgt -NewPassword (ConvertTo-SecureString -AsPlainText "[complex-password-1]" -Force)
# Wait for replication
Start-Sleep -Seconds 300
# Second reset
Set-ADAccountPassword -Identity krbtgt -NewPassword (ConvertTo-SecureString -AsPlainText "[complex-password-2]" -Force)
Persistence Removal
After credential rotation, search for and remove persistence mechanisms:
- Registry Run keys —
HKLM\Software\Microsoft\Windows\CurrentVersion\Run - Scheduled tasks — review all tasks, especially those running as SYSTEM
- Services — check for recently created or modified services
- WMI subscriptions — permanent event subscriptions that execute code
- Startup folders —
shell:startupfor each user - Cron jobs — Linux persistence via crontab
- SSH keys — unauthorized
authorized_keysentries - Web shells — recently modified files in web directories
# Check for WMI permanent event subscriptions
Get-WmiObject -Namespace root\Subscription -Class __EventFilter
Get-WmiObject -Namespace root\Subscription -Class __EventConsumer
Get-WmiObject -Namespace root\Subscription -Class __FilterToConsumerBinding
# Check for recently created services
Get-WmiObject Win32_Service | Where-Object { $_.CreationDate -gt (Get-Date).AddDays(-7) }
Vulnerability Patching
If the attacker exploited a vulnerability for initial access, patch it immediately:
- Identify the vulnerability (from the attack vector analysis)
- Apply the patch or workaround
- Verify the patch was applied successfully
- Scan for other systems with the same vulnerability
Enhanced Monitoring
After containment, increase monitoring on affected systems and the surrounding environment:
- Enable verbose logging on affected systems
- Increase log retention for the investigation period
- Add detection rules for the specific TTPs used by the attacker
- Monitor for re-compromise indicators (same C2 IPs, same malware hashes, same techniques)
The enhanced monitoring period should last at least 14–30 days — long enough to detect re-compromise but not so long that it becomes the new normal.
SOAR Automation
Security Orchestration, Automation, and Response (SOAR) platforms automate containment playbooks. When an alert fires, the SOAR platform executes the playbook steps automatically:
# SOAR playbook: automated ransomware containment
trigger:
alert.rule: "Ransomware Detected"
alert.severity: "critical"
actions:
- name: "Isolate host"
integration: "crowdstrike"
action: "contain_host"
params:
device_id: "{{alert.device_id}}"
on_failure: "notify_soc_manager"
- name: "Block C2 IP"
integration: "palo_alto"
action: "add_address_object"
params:
ip: "{{alert.dest_ip}}"
list: "ransomware-c2"
- name: "Create case"
integration: "service_now"
action: "create_incident"
params:
short_description: "Ransomware on {{alert.host.name}}"
priority: "P1"
assigned_to: "tier2-oncall"
- name: "Notify SOC manager"
integration: "slack"
action: "send_message"
params:
channel: "#soc-critical"
message: "Ransomware contained on {{alert.host.name}}. C2 blocked. Case created."
Automated containment reduces response time from minutes to seconds and eliminates human error during high-pressure situations. However, automation should be carefully tested — a buggy automated playbook can isolate critical production systems or block legitimate traffic.
Practice Problems
Solution
Containment actions in order: (1) Isolate FS-01 from the network immediately — disable network adapters or modify the security group. This stops the ransomware from spreading to other systems while preserving memory for forensic evidence. Do NOT power off — memory contains encryption keys and process evidence. (2) Block the ransomware C2 IPs at the perimeter firewall — prevents the ransomware from receiving commands or exfiltrating data. (3) Identify the ransomware variant — check file extensions, ransom notes, and encrypted file headers. This determines if a decryptor is available. (4) Determine the initial attack vector — phishing? RDP? vulnerability? This is critical for preventing re-compromise. (5) Check for lateral movement — scan other systems for signs of encryption or the same ransomware. (6) Capture memory from FS-01 — preserve evidence before any remediation. (7) Notify SOC manager and CISO — ransomware is a Critical severity incident. (8) Engage cyber insurance carrier. (9) Begin eradication planning — restore from backup vs. rebuild, depending on backup integrity and business impact. Solution
Credential rotation scope: (1) Reset the compromised domain admin password immediately. (2) Reset the KRBTGT account password twice — this invalidates all existing Kerberos tickets, including any Golden Tickets the attacker may have created. Wait for AD replication between resets. (3) Reset passwords for all newly created admin accounts and disable them. (4) Review and reset passwords for all accounts in privileged groups (Domain Admins, Enterprise Admins, Schema Admins) — the attacker may have compromised others. (5) Revoke all Kerberos tickets and active sessions for privileged accounts. (6) Rotate all service account credentials — the attacker had 72 hours to discover and exfiltrate them. (7) Rotate all API keys and tokens for cloud services and applications. (8) Check for and remove unauthorized MFA registrations on compromised accounts. (9) Review authentication logs for the 72-hour period to identify all accounts the attacker accessed. (10) Monitor for re-compromise — the attacker may have created backdoors or persistence mechanisms beyond the known admin accounts. Quiz
1. Why is network isolation preferred over powering off a host during containment?
2. Why is credential rotation performed after containment rather than before?
3. What is the purpose of resetting the KRBTGT account password twice?
4. What is a SOAR platform and how does it help with containment?
5. Why is containment verification important?
Flashcards
Question
What is a containment playbook?
Click to reveal answer
Answer
A pre-scripted, executable procedure for containment actions specific to each incident type. Each step is specific, verifiable, ordered, and conditional. Eliminates ad-hoc decision-making under pressure.
Question
Why is network isolation preferred over powering off?
Click to reveal answer
Answer
Network isolation stops the attack while preserving memory (processes, connections, encryption keys, injected code). Powering off destroys all volatile evidence. Exception: wiper malware actively destroying evidence.
Question
Why is credential rotation performed after containment?
Click to reveal answer
Answer
Rotating credentials before containment may alert the attacker, causing them to accelerate the attack or destroy evidence. Contain first, then rotate — maximizes evidence preservation.
Question
What does resetting KRBTGT twice accomplish?
Click to reveal answer
Answer
Invalidates all existing Kerberos tickets, including Golden Tickets created by an attacker. First reset invalidates pre-existing tickets; second reset (after replication) invalidates tickets created between resets.
Question
What is SOAR?
Click to reveal answer
Answer
Security Orchestration, Automation, and Response — automates containment playbooks. Executes isolation, blocking, and notification in seconds. Reduces response time and human error.
Question
Why is containment verification important?
Click to reveal answer
Answer
A containment step that was not actually executed gives a false sense of security while the attack continues. Verification (ping tests, auth attempts, firewall checks) confirms each step worked.
Revision Notes
Key Takeaways
- 1. Playbooks script containment steps per incident type — specific, verifiable, ordered, conditional
- 2. Network isolation preserves evidence; powering off destroys memory
- 3. Credential rotation follows containment — rotating first may alert the attacker
- 4. KRBTGT reset twice invalidates all Kerberos tickets including Golden Tickets
- 5. SOAR automates containment — reduces response time from minutes to seconds
- 6. Verification confirms each containment step actually worked
Interview Tips
- • Walk through a ransomware containment playbook step by step, explaining the reasoning behind each action
- • Explain why network isolation is preferred over powering off — evidence preservation
- • Discuss credential rotation scope — when to reset a single user vs all privileged accounts
- • Describe the KRBTGT double-reset technique for Golden Ticket mitigation
- • Explain how SOAR automates containment and the importance of testing automated playbooks
- • Discuss containment verification methods and why they prevent false confidence
Cheat Sheet
Containment Playbooks Cheat Sheet
Phase: Detection Engineering and Incident Response | Level: advanced
Playbook design principles:
- Specific over general — "isolate WS-042" not "isolate affected systems"
- Verifiable — each step has a verification method
- Ordered — numbered steps executed in sequence
- Conditional — decision points for different scenarios
- Reversible — document how to undo each step
Isolation techniques:
- Network isolation: disable adapters, modify security groups, VLAN quarantine
- Account isolation: disable accounts, revoke sessions and tokens
- Network-level: firewall rules, DNS sinkhole, BGP blackhole
- Do NOT power off — preserves memory evidence
Post-containment actions:
- Credential rotation — reset compromised passwords, revoke sessions
- KRBTGT reset twice — invalidates all Kerberos tickets (Golden Ticket mitigation)
- Persistence removal — registry, scheduled tasks, services, WMI, cron, SSH keys
- Vulnerability patching — close the initial access vector
- Enhanced monitoring — 14-30 days of increased logging and detection
Credential rotation scope:
- Single user: reset password, revoke sessions, check MFA
- Domain admin: reset password, KRBTGT twice, revoke tickets, check Golden Tickets
- Widespread: reset all privileged accounts, service accounts, API keys, tokens
SOAR automation:
- Automates playbook execution — isolation, blocking, notification
- Reduces response time from minutes to seconds
- Eliminates human error under pressure
- Must be carefully tested to avoid unintended consequences
Verification methods:
- Network isolation: ping test (should timeout)
- Account isolation: authentication attempt (should fail)
- Firewall block: check rule exists and logs hits
- C2 communication: check for blocked connection attempts
Tags: incident-response, playbooks
Continue Learning
Before You Start
- No prerequisites listed.