Careers Post-AI
Security: all chapters

SecurityPart 5: Detection and response

Chapter 19Incident response and forensics

32 min read, 1 lab, Intermediate

When NotPetya hit Maersk in June 2017 the company reinstalled about 4,000 servers and 45,000 PCs, and its only usable copy of Active Directory survived on a domain controller in Ghana that a power cut had knocked offline. This chapter teaches you to run a response that does not depend on luck: organize people, contain without destroying evidence, read memory and disk, and turn it all into a timeline and a report.

After this chapter you can

  • Explain the incident response lifecycle in NIST SP 800-61 Revision 3 and the classic four phases
  • Run triage and communication with clear roles and out-of-band channels
  • Choose containment, eradication and recovery actions and predict their side effects
  • Collect evidence in order of volatility with a defensible chain of custody
  • Analyze a Windows memory image with Volatility 3 and build an incident timeline
  • Adapt the process to cloud incidents and ransomware, and run a blameless review

The response lifecycle

An incident is an event that actually or potentially harms the confidentiality, integrity or availability of a system or its data. Incident response (IR) is the organized way you handle one. NIST SP 800-61 is the most cited guide. Revision 3, finalized in April 2025, replaces the 2012 incident handling guide and frames response as a profile of the NIST Cybersecurity Framework (CSF) 2.0.

Rev. 3 treats three CSF Functions (Govern, Identify, Protect) as preparation and three (Detect, Respond, Recover) as response, with lessons learned feeding improvement everywhere. The four phases from Rev. 2 are still how most teams run an incident hour by hour, so you will hear both vocabularies.

The arrow back from containment to analysis is the part people forget. Every containment action produces new evidence, such as an attacker switching to a backup channel, and you loop until the scope stops growing.

Roles, communication and triage

Incidents fail on coordination more often than on technical skill. Assign roles at the start, even if one person holds several.

RoleOwns
Incident commanderDecisions, priorities, the overall plan; does not do hands-on analysis
Technical leadInvestigation and containment work, assigns analysts
ScribeA timestamped log of every decision and action, in UTC
Communications leadUpdates to executives, staff, customers and, with legal, regulators
Legal and privacyPrivilege, notification duties, law enforcement contact
Subject-matter ownersSystem admins for the affected platforms

Assume the attacker can read your email and chat if identity systems are involved. Move the response to an out-of-band channel, such as a separate tenant or a phone bridge, before you discuss what you know.

Triage answers four questions fast: what happened, how far has it spread, is it still active, and what is the business impact. Those answers set a severity level, and severity sets who gets woken up. Legal clocks may start here too. Examples include the EU GDPR's 72 hours to notify a regulator of a personal data breach, NIS2's 24-hour early warning, and the US SEC's four business days after a public company decides an incident is material.

Containment, eradication and recovery

Containment stops the damage from spreading. Eradication removes the attacker's access and tools. Recovery returns systems to normal operation and watches for the attacker's return. Each step is a decision with trade-offs, not a checklist.

Contain immediately

  • Limits damage, data loss and spread
  • Tips off the attacker, who may switch tools or wipe evidence
  • Right for active destruction, ransomware or data theft in progress

Observe first, then contain all at once

  • Maps every foothold so one coordinated action removes them all
  • Risk grows while you watch
  • Right for a quiet intruder where partial containment would cause a whack-a-mole game
ActionEffectSide effect to plan for
Isolate host with EDRCuts network except to the EDR consoleKeeps memory intact, unlike pulling the power
Disable accountStops new sign-insExisting sessions and refresh tokens may still work; revoke them too
Rotate keys and secretsKills stolen credentialsBreaks integrations that used them; coordinate the cutover
Reset krbtgt twiceInvalidates forged Kerberos tickets (golden tickets)Must be spaced out to avoid breaking replication and authentication
Block egress to attacker IPsCuts known command and control (C2)Attackers usually have more infrastructure; do not rely on it alone

Eradication starts with root cause: how did they get in, and what persistence did they leave? Rebuild compromised systems from known-good images rather than "cleaning" them; you rarely find every implant. Recovery restores data from backups you have checked are clean and from before the intrusion began, then raises monitoring on those systems for weeks.

A ransomware response outline

  1. Isolate, do not power off

    Disconnect affected hosts from the network, using EDR isolation or switch ports. Keep them powered on to preserve memory, which may hold encryption keys; power down only if you cannot disconnect them.

  2. Protect the backups

    Check that backups are offline or immutable and that the attacker has not reached the backup console. Many ransomware crews delete backups before encrypting.

  3. Scope and preserve

    Find the first infected host and how the attacker moved. Capture memory and a disk image from a sample of hosts, the ransom note and a few encrypted files.

  4. Assume data was stolen

    Most crews exfiltrate before encrypting (double extortion). Look for large outbound transfers and archiving tools, and bring in legal for notification decisions.

  5. Reset identity, then rebuild

    Reset privileged credentials, including krbtgt, then rebuild from known-good images and restore clean data. Decisions about payment involve legal counsel, insurers and sanctions checks, never only the security team.

Evidence and the order of volatility

Some evidence disappears in seconds and some lasts years. RFC 3227, the classic guideline for evidence collection, says to collect the most volatile first.

In practice you capture memory first, then disk, then pull logs from central storage. Every item gets a chain-of-custody record: what it is, who collected it, when (in UTC), how, and its cryptographic hash.

hash evidence at acquisition, and again before analysis
sha256sum citadeldc01.mem | tee citadeldc01.mem.sha256
# later, before you start work:
sha256sum -c citadeldc01.mem.sha256

Disk, memory and timeline forensics

Forensics is the reconstruction of what happened from artifacts. Disk holds history; memory holds the present; logs connect the two.

Disk artifacts

PlatformArtifactTells you
Windows$MFT and $UsnJrnl (NTFS metadata and change journal)Which files existed, were created, renamed or deleted, and when
WindowsPrefetch, Amcache, ShimcacheWhich programs ran, roughly when, and from where
WindowsRegistry Run keys, services, scheduled tasksPersistence
WindowsEvent logs (Security, System, Sysmon, PowerShell)Logons, service installs, process launches, script content
Linuxauth.log or the systemd journalLogins, sudo, SSH keys used
Linuxcron, systemd units, ~/.ssh/authorized_keys, shell rc filesPersistence

Standard tools include The Sleuth Kit and Autopsy for file systems, Eric Zimmerman's tools for Windows artifacts, and plaso (log2timeline) to merge them into one super timeline.

Memory with Volatility 3

Memory shows what was running at capture time: processes, network connections, loaded code, command lines, and code injected into legitimate processes that never touched disk. Volatility 3 is the standard open-source framework for reading it. It identifies the operating system automatically and downloads Windows symbol files from Microsoft on first use.

a first pass over a Windows image
vol -f mem.raw windows.info
vol -f mem.raw windows.pstree
vol -f mem.raw windows.psscan              # also finds exited and unlinked processes
vol -f mem.raw windows.cmdline
vol -f mem.raw windows.netscan
vol -f mem.raw windows.malware.malfind     # executable private memory, often injection
vol -r jsonl -f mem.raw timeliner.Timeliner --plugin-filter pslist netscan > timeline.jsonl

Look for anomalies against what normal looks like: a svchost.exe whose parent is not services.exe, a process running from a user's temp folder, a system process holding a connection to an unknown external IP, or a readable-writable-executable memory region that starts with an MZ header.

Building the timeline

A timeline lists every relevant event in UTC with its source and your confidence. Build it from memory (process and connection times), disk (file and execution artifacts) and logs (logons, alerts). Write down when sources disagree; a mismatch often exposes timestomping or a wrong clock.

Incident response in the cloud

Cloud incidents change what evidence exists and how you contain. Identity, not the network, is the main perimeter, and much of the evidence lives in the provider's audit logs.

On premisesIn the cloud
Image the physical diskSnapshot the volume (for example an EBS snapshot) and share it to a separate forensics account
Capture memory with a local toolPossible on VMs with agents, impossible on most managed services; logs matter more
Unplug the network cableSwap the instance to a quarantine security group; already-tracked connections may survive a rule change, so pair it with a network ACL deny
Reset the passwordDeactivate access keys and revoke active sessions; temporary credentials keep working until revoked or expired
Evidence stays until you wipe itAuto-scaling can terminate a compromised instance and its disk; detach it from the group first

Prepare before you need it: a dedicated forensics account, organization-wide audit trails the workload accounts cannot disable, and tested runbooks for snapshotting and isolating each resource type.

Blameless post-incident review

The post-incident review turns pain into improvement. Blameless means you ask how the system allowed the outcome, not who to punish. People who fear blame hide the details you most need.

SectionContent
TimelineWhat happened and when, from first attacker action to full recovery
DetectionHow it was found, and how long after it started
What went wellPractices to keep
Contributing factorsTechnical gaps, process gaps, missing telemetry, unclear ownership
Action itemsEach with one owner and a due date, tracked to completion

Measure the response itself: time to detect, time to contain and time to recover. Track them across incidents to see whether the program is improving. A review whose action items are never finished was only a meeting.

Key terms

Incident
An event that actually or potentially jeopardizes the confidentiality, integrity or availability of a system or data.
NIST SP 800-61
NIST's incident response guidance; Revision 3 (2025) aligns it with CSF 2.0.
Containment
Actions that stop an incident from spreading or causing more damage.
Eradication
Removing the attacker's access, tools and persistence from the environment.
Order of volatility
Collecting the most short-lived evidence, such as memory, before longer-lived evidence such as disk.
Chain of custody
A record of who handled each piece of evidence, when and how, backed by hashes.
Volatility 3
An open-source framework for analyzing memory images from Windows, Linux and macOS.
Process injection
Running attacker code inside another, often legitimate, process's memory.
Blameless review
A post-incident analysis focused on system causes and improvements rather than individual fault.
Lab

Investigate a compromised domain controller from memory

Intermediate, 3 hours

Goal: analyze the memory image of a breached Windows Server 2012 R2 domain controller from the public DFIR Madness "Stolen Szechuan Sauce" practice case, identify the malicious process, its network activity and its injection, build a UTC timeline and write a short incident report.

You need: Python 3.10 or newer, about 6 GB of free disk, and internet access the first time Volatility runs (it downloads Windows symbols). The image is a deliberately compromised lab system published for training, so analyzing it is safe and legal. Do not upload it or extracted files to public scanning services; the case author published answers you can compare against afterwards.

  1. Set up a case folder and install Volatility 3.
mkdir -p ~/ir/case001 && cd ~/ir/case001
python3 -m venv ~/ir/.venv && . ~/ir/.venv/bin/activate
pip install -q volatility3
vol -h | head -1

Expect a usage line; pip show volatility3 should report 2.28 or newer.

  1. Download the image, verify it against the hash the case author published, and start your evidence log.
curl -LO https://dfirmadness.com/case001/DC01-memory.zip
md5sum DC01-memory.zip 2>/dev/null || md5 DC01-memory.zip
unzip DC01-memory.zip && ls -lh citadeldc01.mem
shasum -a 256 citadeldc01.mem | tee citadeldc01.mem.sha256
printf '# Evidence log\n%s UTC  acquired DC01-memory.zip, md5 checked, sha256 recorded\n' "$(date -u '+%F %T')" > notes.md

The MD5 must equal 64a4e2cb47138084a5c2878066b2d7b1 (case does not matter). The .mem file is 2 GB.

  1. Identify the system and its clock. Save every plugin's output to a file so your report can cite it.
vol -f citadeldc01.mem windows.info | tee info.txt

Note the build and SystemTime. The case author warns that this lab VM's UTC clock is off, so record what the image claims and treat later times as relative until you can corroborate them.

  1. Survey processes and look for the odd one out.
vol -f citadeldc01.mem windows.pstree  | tee pstree.txt
vol -f citadeldc01.mem windows.psscan  | tee psscan.txt
vol -f citadeldc01.mem windows.cmdline | tee cmdline.txt

Compare each process's name, parent and path with what belongs on a domain controller. Look for an executable whose name sounds like a system updater but runs from an unusual folder. Record its PID, parent PID and creation time in notes.md.

  1. Find the network connections and who owns them.
vol -f citadeldc01.mem windows.netscan | tee netscan.txt
grep -v -E '0\.0\.0\.0|::|127\.0\.0\.1' netscan.txt | grep -i -E 'ESTABLISHED|CLOSED' | head -40

Note any connection to an address outside the lab's private range and the PID that owns it. A legitimate Windows service talking to the same external address as your suspicious process is a strong hint of migration or injection.

  1. Hunt for injected code.
vol -f citadeldc01.mem windows.malware.malfind | tee malfind.txt
awk '$2 ~ /\.exe$/ {print $1, $2}' malfind.txt | sort | uniq -c

malfind lists private memory regions that are executable and writable. Some hits are benign (just-in-time compilers do this), but a region starting with 4d 5a (MZ, the start of a Windows executable) inside a service process is a classic sign of injection. To extract a region for offline study, rerun with --pid <PID> --dump; scan the dumps locally with ClamAV (clamscan *.dmp) if you have it.

  1. Check persistence.
vol -f citadeldc01.mem windows.svcscan | tee svcscan.txt
# HKLM Run key (path is relative to the SOFTWARE hive), then per-user Run keys in NTUSER.DAT hives
vol -f citadeldc01.mem windows.registry.printkey --key 'Microsoft\Windows\CurrentVersion\Run' | tee runkeys.txt
vol -f citadeldc01.mem windows.registry.printkey --key 'Software\Microsoft\Windows\CurrentVersion\Run' | tee -a runkeys.txt
grep -i -n '<suspicious name>' svcscan.txt runkeys.txt

Replace <suspicious name> with the executable you found in step 4.

  1. Build a timeline. Timeliner collects every timestamp that the selected plugins know about; the script sorts and filters it.
vol -r jsonl -f citadeldc01.mem timeliner.Timeliner --plugin-filter pslist netscan > timeline.jsonl
~/ir/case001/timeline.py
#!/usr/bin/env python3
"""Sort Volatility timeliner JSONL output and filter it by time or text.
 
usage: python3 timeline.py timeline.jsonl [--after 2020-09-19T00:00] [--before ...] [--grep text]
"""
import argparse
import json
 
ap = argparse.ArgumentParser()
ap.add_argument("file")
ap.add_argument("--after", help="ISO time, UTC, e.g. 2020-09-19T02:00")
ap.add_argument("--before", help="ISO time, UTC")
ap.add_argument("--grep", help="case-insensitive text filter")
args = ap.parse_args()
 
rows = []
with open(args.file, encoding="utf-8") as f:
    for line in f:
        if not line.lstrip().startswith("{"):
            continue
        r = json.loads(line)
        for col in ("Created Date", "Modified Date", "Accessed Date", "Changed Date"):
            if r.get(col):
                rows.append((r[col][:19], col.split()[0], r.get("Plugin", ""), r.get("Description", "")))
 
for when, kind, plugin, desc in sorted(rows):
    if args.after and when < args.after:
        continue
    if args.before and when > args.before:
        continue
    if args.grep and args.grep.lower() not in f"{plugin} {desc}".lower():
        continue
    print(f"{when}Z  {kind:<8} {plugin:<24} {desc}")
python3 timeline.py timeline.jsonl | tail -40
python3 timeline.py timeline.jsonl --grep '<suspicious name>'

Find the creation of the suspicious process, then widen the window around it with --after and --before to see what started just before and after.

  1. Write the report. Keep it to two pages and make every claim cite an output file.
~/ir/case001/report.md
# Incident report: CASE-001, DC01
 
## Executive summary
Three to five sentences: what happened, impact, current status, what we recommend.
 
## Evidence
| Item | SHA-256 | Acquired (UTC) | Notes |
| --- | --- | --- | --- |
| citadeldc01.mem | ... | ... | Clock offset noted in info.txt |
 
## Timeline (UTC, image clock)
| Time | Source file | Event | Confidence |
| --- | --- | --- | --- |
 
## Findings
- Malicious process: name, PID, path, parent (pstree.txt, cmdline.txt)
- Network: remote IP and port, owning PIDs (netscan.txt)
- Injection: process and region (malfind.txt)
- Persistence: service or Run key (svcscan.txt, runkeys.txt)
 
## ATT&CK mapping
| Technique | Evidence |
| --- | --- |
 
## Recommendations
Containment, eradication and recovery steps, each with an owner.
 
## Gaps and open questions
What memory alone cannot answer, and which artifact would (disk, logs, PCAP).

Check your work: your report names one malicious executable with its full path, at least one external IP it or an injected process connected to, the process that holds injected code, and a timeline of at least eight events. Compare your conclusions with the case author's published answers at dfirmadness.com, and note anything you missed and why.

Stretch: download the case's PCAP from the same page, run it through Zeek in Docker (docker run --rm -v "$PWD":/pcap zeek/zeek zeek -C -r /pcap/<file>.pcap), and add network evidence to your timeline. Do the times agree with memory once you account for the clock offset?

Check yourself

Ransomware is actively encrypting file servers. Which first action best balances stopping damage with preserving evidence?

You disabled a compromised user's account, yet the attacker keeps reading their mailbox an hour later. What is the most likely reason?

Volatility's pslist does not show a process, but psscan does. What does that tell you?

Why do cloud responders often add a network ACL deny in addition to moving an instance into a quarantine security group?

Recap

  • NIST SP 800-61 Rev. 3 frames response around CSF 2.0; the four classic phases still run the incident hour by hour.
  • Clear roles, a scribe and out-of-band communication prevent the most common failures.
  • Containment is a trade-off between speed and completeness; revoke sessions, rotate secrets and rebuild rather than clean.
  • Collect evidence in order of volatility, hash it, and record the chain of custody.
  • Volatility 3 reveals processes, connections and injected code that disk alone misses; the timeline ties every source together in UTC.
  • Cloud response is identity- and log-centric, and a blameless review with owned action items is what makes the next incident smaller.

Go deeper