Detection, Analysis and Containment
The alert from the previous lessons is confirmed: labagent.exe on one laptop is malicious. The next hour decides how expensive the incident becomes. Three things have to happen, partly in parallel: scope it (is it one laptop or fifty?), decide severity (who must be woken up, which reporting clocks start), and contain it (stop it spreading or doing more harm) without destroying the evidence or tipping off an attacker who still has other ways in. In CSF 2.0 terms this is Detect (DE.AE adverse event analysis) flowing into Respond: RS.MA (incident management), RS.AN (analysis) and RS.MI (mitigation) (lifecycle).
Definitions
- Event, alert, incident: an event is anything observable; an alert is an event a detection flagged; an incident is a confirmed (or strongly suspected) violation of security policy that needs a response. Most alerts are not incidents; triage decides.
- Scoping: finding every affected host, account and data set, by hunting for the incident's indicators and behaviours across the environment.
- Severity: usually a matrix of impact (what is affected: one laptop, a domain controller, customer data) and urgency or spread; it sets who is involved and how fast.
- Containment: actions that stop further harm. Short-term: isolate hosts (EDR network isolation), block domains and IPs, disable or reset accounts, revoke sessions and tokens. Long-term: segmentation changes, temporary hardening, patching, while eradication is prepared.
- Watch or act: sometimes responders deliberately delay containment to learn the attacker's scope (in serious intrusions with a capable adversary), accepting risk for a better eradication later. It is a decision for the incident commander, with management, and it is the exception.
Scoping and choosing containment
The example scopes the lab case with synthetic telemetry: it searches DNS logs, proxy logs and EDR file events for the indicators from the analysis, groups hits per host, and proposes containment actions per host from a severity matrix. One more host appears that the first alert didn't show.
import pandas as pd
IOCS = {"domain": "update.beacon.lab.test", "sha256": "4e1f0c…c3a9", "mutex": "Global\\LabAgent-Mutex-7f3a"}
dns = pd.DataFrame([("lt-0815", "2026-01-15 10:06:13", "update.beacon.lab.test"),
("lt-0815", "2026-01-15 10:06:13", "www.lab.test"),
("srv-files01", "2026-01-15 10:41:02", "update.beacon.lab.test"),
("lt-0907", "2026-01-15 10:12:40", "intranet.lab.test")], columns=["host", "time", "query"])
edr = pd.DataFrame([("lt-0815", "2026-01-15 10:04:02", "file_created", "4e1f0c…c3a9"),
("srv-files01", "2026-01-15 10:40:55", "file_created", "4e1f0c…c3a9"),
("srv-files01", "2026-01-15 10:40:57", "mutex_created", "Global\\LabAgent-Mutex-7f3a"),
("lt-0907", "2026-01-15 10:30:00", "file_created", "9b9b77…0001")],
columns=["host", "time", "event", "value"])
assets = {"lt-0815": ("laptop", "low"), "srv-files01": ("file server", "high"), "lt-0907": ("laptop", "low")}
hits = pd.concat([
dns[dns["query"] == IOCS["domain"]].assign(evidence="dns " + dns["query"]),
edr[edr.value.isin([IOCS["sha256"], IOCS["mutex"]])].assign(evidence=lambda d: d.event + " " + d.value),
])[["host", "time", "evidence"]].sort_values(["host", "time"])
print(hits.to_string(index=False))
def severity(criticality, hosts):
if criticality == "high" or hosts > 5:
return "SEV-1"
return "SEV-2" if hosts > 1 else "SEV-3"
affected = hits.host.unique()
print("\naffected hosts:", list(affected))
for h in affected:
kind, crit = assets[h]
sev = severity(crit, len(affected))
actions = ["capture memory", "EDR network isolation"] if kind == "laptop" else \
["capture memory", "snapshot VM disk", "isolate to a quarantine VLAN", "fail over the file share"]
print(f"{h:<12} {kind:<12} {sev} -> {', '.join(actions)}")
print("everywhere: block", IOCS["domain"], "at proxy and DNS; reset the credentials used on affected hosts") host time evidence
lt-0815 2026-01-15 10:04:02 file_created 4e1f0c…c3a9
lt-0815 2026-01-15 10:06:13 dns update.beacon.lab.test
srv-files01 2026-01-15 10:40:55 file_created 4e1f0c…c3a9
srv-files01 2026-01-15 10:40:57 mutex_created Global\LabAgent-Mutex-7f3a
srv-files01 2026-01-15 10:41:02 dns update.beacon.lab.test
affected hosts: ['lt-0815', 'srv-files01']
lt-0815 laptop SEV-2 -> capture memory, EDR network isolation
srv-files01 file server SEV-1 -> capture memory, snapshot VM disk, isolate to a quarantine VLAN, fail over the file share
everywhere: block update.beacon.lab.test at proxy and DNS; reset the credentials used on affected hosts
The file server is the surprise. Its first indicator appears about 37 minutes after the laptop's (10:40:55 against 10:04:02), which suggests the sample (or its operator) reached it from the laptop, and it makes the whole incident SEV-1 (an incident takes the highest severity of its parts) because of what the server holds. The containment differs by host: a laptop can simply be isolated; a file server needs a business decision (fail over, or accept downtime), and its disk should be preserved first as a VM snapshot. lt-0907 had a DNS query and a file event, but neither matches the indicators: it is not in scope (yet).
How detection quality affects response
- Detection sources: EDR, SIEM correlation, IDS, user reports, third parties (a partner, a researcher, law enforcement). Faster detection means smaller scope; dwell time is the number to track.
- Triage: confirm (true positive?), classify (malware, account compromise, data leak…), set severity, open the incident, assign a commander.
- Analysis in parallel with containment: malware analysis yields IOCs, IOCs feed the scope hunt, the hunt changes containment. Iterate until a hunt finds nothing new.
How to contain well
- Preserve before you contain where it costs little: memory first, then isolate (order of volatility). EDR isolation keeps the host reachable by the EDR console, so collection can continue.
- Contain identities, not only hosts: credentials used on an infected host must be assumed stolen; reset them and revoke sessions and tokens, privileged ones first.
- Contain all known footholds at the same time in a serious intrusion: blocking one beacon while the attacker has three others warns them and leaves them inside.
- Communicate: containment breaks things (an isolated server, a blocked domain); tell the people affected, through channels the attacker can't read if mail may be compromised (communication).
Pitfalls
- Stopping at the first host. The first alert is rarely the first infection.
- Wiping before scoping. Reimaging the laptop at 10:30 would have destroyed the evidence that pointed to the file server.
- Blocking only the IP while the domain moves to a new one; block the domain, and hunt for the behaviour.
- Using compromised channels: discussing the response in the mailbox of a compromised account.
Practice
1. Why did the file server raise the severity to SEV-1 although only two hosts were affected?
The matrix uses impact as well as spread: a high-criticality asset (shared data, many users) makes any confirmed compromise SEV-1.
2. Add a rule: any host with the mutex but no file event is "memory-only, check for fileless persistence". Where would it fire?
Compare the sets of hosts with mutex_created and with file_created for the sample's hash. In this data both events exist on srv-files01, so it would not fire; on a host where the payload ran only in memory, it would.
3. When might an incident commander delay containment?
When there is evidence of a capable attacker with several footholds, and acting on one would warn them before the others are found, the commander may monitor closely for a limited time to scope fully, then contain everything at once. The risk must be accepted by management and limited (for example, by blocking data exfiltration paths meanwhile).
Test yourself
What is scoping in incident response?
- Writing the final report
- Finding every affected host, account and data set
- Choosing a sandbox
- Buying cyber insurance
Why capture memory before isolating or reimaging a host?
- Isolation deletes the disk
- Memory holds volatile evidence (processes, connections, decrypted payloads) that may be lost
- It is faster
- EDR requires it
Credentials were used on an infected laptop. What should containment include?
- Nothing, if the laptop is isolated
- Resetting those credentials and revoking their sessions and tokens
- Changing the laptop's IP address
- Disabling DNS
In the example, why was lt-0907 not added to the scope?
- It was offline
- None of its events matched the incident's indicators
- It is a laptop
- It is in another country