Skip to main content

Lesson 3 of 10

Containment Strategies

Containment stops the spread of an incident while preserving the ability to investigate. The containment strategy depends on incident type, business criticality of affected systems, and the attacker's apparent goals.

40 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Containment Decision Framework

Containment Decision Framework
# Containment trade-offs - balance investigation vs. damage limitation

FULL ISOLATION (immediately sever network connectivity):
  When: Active ransomware encrypting, active data exfiltration, C2 beacon with exec commands
  How: Pull network cable, disable NIC in hypervisor, apply firewall block rule
  Trade-off: Attacker loses connection (may trigger kill switch), volatile network data preserved in memory

MONITORING (watch without acting):
  When: You want to understand the full attack scope; attacker not causing immediate damage
  How: Capture all traffic via packet capture, enhanced logging, honeypot setup
  Duration: Hours maximum - not days - risk of further damage
  Trade-off: Allows collection of threat intelligence (IOCs, C2 infrastructure)

SEGMENTED ISOLATION (remove from production segment but keep accessible for analysis):
  When: Need to continue forensic investigation while preventing lateral movement
  How: Move to isolated forensic VLAN reachable by IR team only
  Trade-off: Best of both worlds for stable compromises without active exfiltration

CREDENTIAL RESET (without isolating systems):
  When: Credential compromise without confirmed system compromise
  How: Force password reset for all affected accounts, revoke all sessions
  When NOT: If attacker has installed backdoors - credential reset alone doesn't evict them

Network Containment Actions

Network Containment Actions
# Containment playbook - network-level actions

# 1. Block attacker's C2 at firewall (preserve connection for monitoring)
iptables -A OUTPUT -d 185.220.101.47 -j DROP    # Block outbound to C2 IP
iptables -A OUTPUT -d malware-c2.example.com -j DROP

# 2. Isolate compromised host to forensic VLAN
# (On managed switch - Cisco CLI)
# interface GigabitEthernet0/1
#   switchport access vlan 999  # Move to isolated forensic VLAN
#   no shutdown

# 3. Block compromised account (Azure AD / on-prem AD)
# Azure AD:
Connect-AzureAD
Set-AzureADUser -ObjectId compromised@company.com -AccountEnabled $false

# On-prem AD:
Disable-ADAccount -Identity "compromised_user"
# Invalidate all Kerberos tickets (force re-authentication):
Get-ADUser compromised_user | Set-ADUser -Replace @{msDS-KeyVersionNumber=100000}

# 4. Revoke all active sessions (OAuth tokens)
# If using Auth0: POST /api/v2/users/{userId}/logout
# If using Okta: POST /api/v1/sessions/{sessionId}/lifecycle/invalidate

# 5. Packet capture for evidence preservation
tcpdump -i eth0 -w /secure-storage/capture_$(date +%Y%m%d_%H%M%S).pcap
# Capture for forensic analysis and evidence preservation

Common Mistakes

  • Aggressive containment without evidence preservation - disabling accounts and pulling cables before capturing evidence destroys critical forensic data
  • Partial containment - isolating only the initially identified system while attacker has already moved laterally to three other hosts
  • Not monitoring post-containment for re-compromise attempts - attackers often have secondary access paths; watch for new login attempts, new C2 connections, or lateral movement from adjacent systems

Tip

Tip

Practice Containment Strategies in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of Containment Strategies from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Containment Strategies is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • Containment stops the spread of an incident while preserving the ability to investigate.
  • Aggressive containment without evidence preservation - disabling accounts and pulling cables before capturing evidence destroys critical forensic data
  • Partial containment - isolating only the initially identified system while attacker has already moved laterally to three other hosts
  • Not monitoring post-containment for re-compromise attempts - attackers often have secondary access paths; watch for new login attempts, new C2 connections, or lateral movement from adjacent systems

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done