Learning path
Digital forensics & incident response

DFIR: Digital Forensics & Incident Response

Detection fires the alarm. DFIR answers the next questions: what happened, how deep does it go, how do we stop it, and what do we change so it never happens again — all without destroying the evidence.

In this lesson

01

What DFIR Is and Where It Sits

Key points

  • DFIR = Digital Forensics (sound collection, preservation and analysis of digital evidence) + Incident Response (the coordinated process to detect, contain, eradicate and recover from a security incident). Forensics answers "what happened and how"; IR drives "stop it and restore service".
  • DFIR begins after detection: the SOC/SIEM/EDR raises an alert, IR triages and scopes it, forensics reconstructs the timeline and root cause, and lessons learned feed back into detection and hardening.
  • Locard's exchange principle underpins all forensics: every interaction leaves a trace, so attacker activity always leaves recoverable artifacts on disk, in memory, on the network and in logs.
  • Goals are dual and sometimes in tension: restore business operations fast vs preserve evidence intact (potentially for legal/HR/law-enforcement use). The IR plan must state which takes priority per scenario.
  • Dwell time (attacker presence before detection) is frequently weeks to months, so forensics must reconstruct historical activity, not just the current state.

References

NIST SP 800-61r2 (Computer Security Incident Handling Guide)
NIST SP 800-86 (Guide to Integrating Forensic Techniques into Incident Response)
ISO/IEC 27037:2012
ISO/IEC 27035-1:2023 (Information security incident management)
02

The NIST SP 800-61 Incident Response Lifecycle

Key points

  • NIST SP 800-61 Rev 2 defines a four-phase lifecycle: (1) Preparation; (2) Detection & Analysis; (3) Containment, Eradication & Recovery; (4) Post-Incident Activity. The phases are cyclical, not linear — analysis and containment iterate as scope expands.
  • Preparation: build the IR plan, jump kit, contact tree, communications/escalation paths, baselines, and the detection tooling (SIEM, EDR, logging) BEFORE an incident — most response failures trace to weak preparation.
  • Detection & Analysis: validate the alert, determine scope (which hosts/accounts/data), classify severity, and correlate indicators across sources; precursors warn of possible attacks, indicators show one is occurring or has occurred.
  • Containment, Eradication & Recovery: short-term containment (isolate host, block C2) buys time; eradication removes the foothold (malware, persistence, attacker accounts); recovery restores systems to known-good and monitors for re-infection. Containment strategy must weigh evidence preservation vs damage limitation.
  • Post-Incident Activity: the 'lessons learned' meeting captures root cause, timeline, what worked, and concrete improvements; metrics (dwell time, MTTD, MTTR) drive program maturity.
  • SANS teaches an equivalent six-step model (PICERL): Preparation, Identification, Containment, Eradication, Recovery, Lessons Learned — it maps cleanly onto the NIST phases.
  • ISO/IEC 27035 provides the management-system view of the same lifecycle (plan & prepare, detection & reporting, assessment & decision, responses, lessons learned).

References

NIST SP 800-61r2 (Computer Security Incident Handling Guide)
ISO/IEC 27035-1:2023
ISO/IEC 27035-2:2023
03

Evidence Handling: Chain of Custody and Integrity

Key points

  • Chain of custody is a documented, unbroken record of who collected each item, when, where, why, and every transfer/handoff — without it, evidence may be inadmissible and conclusions are disputable.
  • Cryptographic hashing proves integrity: compute a hash (SHA-256 recommended) of an acquired image at collection, store it, and re-hash on every analysis copy — matching hashes prove the evidence was not altered.
  • MD5 and SHA-1 are cryptographically broken for collision resistance but are still widely used in forensics for integrity verification of an already-collected image (an attacker cannot retroactively alter evidence you already hashed); SHA-256 is the modern default.
  • Write-blockers (hardware or software) sit between the evidence drive and the analysis workstation to permit reads but block all writes, preserving the original media unaltered during acquisition.
  • Always work from a forensic image, never the original: acquire a bit-for-bit copy (e.g., raw/dd or E01/EWF), verify the hash, then analyse copies of the image.
  • Document everything contemporaneously: photos, serial numbers, timestamps (with timezone), tool versions and command lines — reproducibility is what makes findings defensible.

References

NIST SP 800-86 (Guide to Integrating Forensic Techniques into Incident Response)
ISO/IEC 27037:2012 (identification, collection, acquisition, preservation of digital evidence)
RFC 3227 (Guidelines for Evidence Collection and Archiving)
ISO/IEC 27041:2015
ISO/IEC 27042:2015
04

Order of Volatility (RFC 3227)

Key points

  • RFC 3227 codifies the order of volatility: collect the most ephemeral evidence first because it disappears fastest. Getting the order wrong destroys data you can never recover.
  • Canonical order, most to least volatile: (1) CPU registers and cache; (2) routing table, ARP cache, process table, kernel statistics, RAM; (3) temporary filesystems; (4) disk; (5) remote logging and monitoring data; (6) physical configuration and network topology; (7) archival media.
  • Practical consequence: capture a RAM image and live volatile state (network connections, running processes) BEFORE powering off or imaging disk — pulling the plug destroys memory-resident malware, keys and connections.
  • RFC 3227 also mandates minimizing changes to the evidence, documenting actions and timestamps, and avoiding running untrusted tools on the suspect system (use known-good trusted binaries).
  • NIST SP 800-86 gives a complementary forensic process (collection, examination, analysis, reporting) that operationalizes volatility-aware acquisition.

References

RFC 3227 (Guidelines for Evidence Collection and Archiving)
NIST SP 800-86
05

Memory Forensics

Key points

  • RAM holds artifacts that exist nowhere on disk: running and hidden processes, active network connections, loaded modules/DLLs, injected/unpacked code, command-line arguments, clipboard, and sometimes encryption keys and decrypted payloads.
  • The Volatility Framework is the de-facto open-source memory analysis tool; acquisition tools include WinPmem, DumpIt, AVML (Linux) and LiME (Linux Memory Extractor).
  • Core analyses: enumerate processes and spot anomalies (parent-child mismatches, masquerading), list network connections, detect process injection and code hiding, dump suspicious process memory, and recover command history.
  • Memory forensics is the primary way to find fileless and in-memory-only malware (process injection, reflective DLL loading) that leaves little or no disk footprint — ATT&CK T1055 Process Injection.
  • Memory is extremely volatile and changes constantly; image it early in live response, and record acquisition time/tool/hash for the chain of custody.

References

NIST SP 800-86
MITRE ATT&CK T1055 (Process Injection)
MITRE ATT&CK T1003 (OS Credential Dumping)
RFC 3227
06

Disk Forensics: Timelines, NTFS Metadata and Recovery

Key points

  • Timeline analysis reconstructs the sequence of events by combining filesystem timestamps, logs and artifacts; super-timeline tools (Plaso/log2timeline) merge dozens of sources into one chronological view.
  • NTFS stores file metadata in the Master File Table ($MFT); each record holds timestamps in two attributes — $STANDARD_INFORMATION (user/API-writable) and $FILE_NAME (harder to forge) — comparing them helps detect timestamp tampering.
  • The $UsnJrnl change journal ($Extend\$UsnJrnl:$J) records file create/rename/delete/modify events, and $LogFile records transactional metadata — both are gold for proving file activity even after deletion.
  • Deleted-file recovery uses two techniques: recovering still-allocated metadata (a deleted file's $MFT record/pointers may survive until overwritten) and file carving (rebuilding files from raw data by header/footer signatures in unallocated space).
  • Windows artifact sources reveal execution and access: Prefetch (program execution), Amcache/Shimcache, registry hives (SYSTEM, SOFTWARE, SAM, NTUSER.DAT), LNK files, Jump Lists and the SRUM database.
  • Autopsy (GUI front-end to The Sleuth Kit) and KAPE are standard for disk image analysis and targeted artifact collection.

References

NIST SP 800-86
MITRE ATT&CK T1070.006 (Indicator Removal: Timestomp)
MITRE ATT&CK T1070.004 (Indicator Removal: File Deletion)
07

Network Forensics

Key points

  • Two evidence tiers: full packet capture (PCAP) gives complete content but is storage-heavy and short-lived; flow/session data (NetFlow/IPFIX) is lightweight metadata (who talked to whom, when, how much) retained far longer.
  • PCAP analysis (Wireshark, tcpdump) reconstructs sessions, extracts transferred files, and exposes C2 beaconing, exfiltration and lateral movement; Zeek (formerly Bro) turns raw traffic into rich structured logs (DNS, HTTP, TLS, conn).
  • TLS/encrypted traffic can still be fingerprinted via metadata: JA3/JA3S client/server TLS fingerprints, certificate details, SNI, and beaconing timing/jitter patterns help identify malicious tooling without decryption.
  • DNS is a high-value forensic source: lookups reveal C2 domains, DGA patterns, and DNS-tunneling exfiltration even when payloads are encrypted.
  • Suricata and Zeek provide IDS/NSM telemetry that bridges detection and forensics; NetFlow is invaluable for scoping ('which other hosts contacted this C2?').

References

NIST SP 800-86
RFC 3954 (Cisco Systems NetFlow Services Export Version 9)
RFC 7011 (IPFIX Protocol Specification)
MITRE ATT&CK T1071 (Application Layer Protocol)
MITRE ATT&CK T1048 (Exfiltration Over Alternative Protocol)
08

Cloud Forensics

Key points

  • Cloud changes the evidence model: you rarely seize hardware. Instead you acquire volume snapshots (e.g., AWS EBS snapshots, Azure managed-disk snapshots, GCP persistent-disk snapshots) and analyse copies, preserving the original.
  • Control-plane logs are the primary evidence: AWS CloudTrail, Azure Activity Log / Entra ID sign-in & audit logs, and Google Cloud Audit Logs record API calls (who did what, from where) — these reconstruct attacker actions on the cloud account itself.
  • Key challenges: ephemerality (autoscaled instances vanish), multi-tenancy, limited access to the hypervisor/underlying host, and the shared-responsibility model defining what the provider vs customer can collect.
  • Attackers commonly disable or tamper with cloud logging to evade forensics — ATT&CK T1562.008 Disable or Modify Cloud Logs; defenders should ship logs to a separate, append-only account/bucket out of the workload’s reach.
  • Prepare for cloud DFIR in advance: enable org-wide CloudTrail/audit logging, immutable log storage, and automated snapshot/isolation runbooks, because you cannot retroactively collect logs that were never enabled.

References

NIST IR 8006 (Cloud Computing Forensic Science Challenges)
MITRE ATT&CK T1562.008 (Impair Defenses: Disable or Modify Cloud Logs)
MITRE ATT&CK T1530 (Data from Cloud Storage)
MITRE ATT&CK T1578 (Modify Cloud Compute Infrastructure)
NIST SP 800-86
09

Triage and Live Response

Key points

  • Triage prioritizes effort under time pressure: quickly determine if a host is compromised, the severity, and what to collect, so analysts focus on the systems that matter most.
  • Live response collects volatile and targeted artifacts from a running system without full disk imaging: running processes, network connections, logged-on users, scheduled tasks, autoruns/persistence, and recent logs.
  • Use trusted, known-good tools run from external media (RFC 3227) and minimize footprint; record every command and its output with timestamps for the chain of custody.
  • DFIR-at-scale tooling: Velociraptor and GRR (endpoint hunting/collection across a fleet), KAPE and CyLR (targeted artifact collection), and Sysmon for rich, pre-deployed Windows event telemetry.
  • Containment decisions happen during triage: network-isolate vs power-off vs leave-running-to-observe — each trades evidence preservation against attacker dwell and damage.

References

NIST SP 800-61r2
NIST SP 800-86
RFC 3227
10

Indicators of Compromise and the Pyramid of Pain

Key points

  • Indicators of Compromise (IOCs) are observable artifacts of an intrusion — file hashes, IP addresses, domains, URLs, registry keys, mutexes — used to detect and scope attacker presence.
  • IOCs (atomic forensic evidence of what happened) differ from IOAs (Indicators of Attack — behavior/intent in progress); mature programs hunt on both.
  • David Bianco's Pyramid of Pain ranks indicators by how much pain denying them causes the adversary, bottom to top: hash values, IP addresses, domain names, network/host artifacts, tools, and TTPs.
  • Hashes and IPs are trivial for attackers to change (low pain); detecting on tools and especially TTPs forces costly attacker retooling (high pain) — so detection engineering should climb the pyramid.
  • Standard IOC/intel formats enable sharing and automation: STIX/TAXII (structured threat intel exchange), Sigma (SIEM detection rules), and YARA (file/memory pattern matching).

References

MITRE ATT&CK (Enterprise tactics & techniques framework)
STIX 2.1 (OASIS Structured Threat Information Expression)
TAXII 2.1 (OASIS Trusted Automated Exchange of Intelligence Information)
11

Basic Malware Triage: Static vs Dynamic

Key points

  • Static analysis examines the sample without executing it: file type and hashes, strings, PE/ELF headers, imports/exports, embedded resources, packing/entropy, and YARA-rule matching — fast and safe but defeated by packing/obfuscation.
  • Dynamic analysis detonates the sample in an isolated sandbox and observes behavior: files/registry written, processes spawned, network connections and C2, persistence — reveals real behavior but evasive malware may detect the sandbox and stay dormant.
  • Sandboxing must be isolated (no production network reachability) to prevent the malware spreading; sandbox-aware malware checks for VM/analysis artifacts and may require anti-evasion measures.
  • Core tooling: YARA (signature/pattern matching), capa (capability identification), PE inspection utilities, and automated sandboxes such as Cuckoo/CAPE; obfuscated samples (ATT&CK T1027) require unpacking before useful static analysis.
  • Triage output is actionable: extracted IOCs (hashes, C2 domains/IPs), a YARA/Sigma detection, classification/family, and a confidence level — feeding scoping and detection.

References

MITRE ATT&CK T1027 (Obfuscated Files or Information)
MITRE ATT&CK T1140 (Deobfuscate/Decode Files or Information)
MITRE ATT&CK T1059 (Command and Scripting Interpreter)
NIST SP 800-83r1 (Guide to Malware Incident Prevention and Handling for Desktops and Laptops)
12

Anti-Forensics Awareness

Key points

  • Attackers actively destroy and falsify evidence; forensic analysts must know these techniques to spot tampering and find what survives. Indicator Removal is a whole ATT&CK technique family (T1070).
  • Timestomping (T1070.006) forges file MAC times to blend malware into the OS timeline; detect it by comparing NTFS $STANDARD_INFORMATION vs $FILE_NAME timestamps and by cross-referencing $UsnJrnl/$LogFile.
  • Log clearing (T1070.001 Clear Windows Event Logs, T1070.002 Clear Linux or Mac System Logs) erases the audit trail; defenses are centralized/forwarded logging and append-only/WORM storage so a cleared local log is still preserved upstream.
  • File deletion and secure wiping (T1070.004) aim to remove tools and data — but carving, $MFT residue, $UsnJrnl entries and memory artifacts frequently still recover evidence.
  • Other anti-forensics: hiding artifacts (T1564), disabling security/logging tooling (T1562), and clearing command history; inhibiting recovery via shadow-copy deletion (T1490) is common before ransomware.
  • Defensive principle: get evidence off the endpoint fast (log forwarding, EDR telemetry, immutable storage) so an attacker who controls the host cannot retroactively erase the record.

References

MITRE ATT&CK T1070 (Indicator Removal)
MITRE ATT&CK T1070.006 (Timestomp)
MITRE ATT&CK T1070.001 (Clear Windows Event Logs)
MITRE ATT&CK T1070.002 (Clear Linux or Mac System Logs)
MITRE ATT&CK T1070.004 (File Deletion)
MITRE ATT&CK T1564 (Hide Artifacts)
MITRE ATT&CK T1562 (Impair Defenses)
MITRE ATT&CK T1490 (Inhibit System Recovery)
OWASP A09:2021 Security Logging and Monitoring Failures
CWE-778 (Insufficient Logging)
13

Reporting and Lessons Learned

Key points

  • The incident report is the durable deliverable: executive summary, scope, timeline of attacker actions, root cause, evidence (with hashes), impact, and remediation/recommendations — written for both technical and management audiences.
  • Map confirmed attacker activity to MITRE ATT&CK techniques so findings are standardized, comparable, and directly translatable into detections and coverage gaps.
  • The lessons-learned (post-incident) meeting answers: what happened, how well did we respond, what would we change, and which detections/controls/playbooks must be updated — closing the loop back to Preparation.
  • Track program metrics across incidents — dwell time, mean time to detect (MTTD), mean time to respond (MTTR), and recurrence — to demonstrate and drive improvement.
  • Preserve evidence and documentation per retention/legal requirements; reproducibility (tool versions, commands, hashes) is what makes a report defensible if it is ever scrutinized legally.

References

NIST SP 800-61r2 (Post-Incident Activity)
MITRE ATT&CK (technique mapping for reporting)
ISO/IEC 27035-2:2023

Detection feeds DFIR

Every forensic timeline starts with a signal someone chose to log. See how detection engineering builds the alerts that launch the whole DFIR loop.

Detection engineering →