open atlas
↑ Back to track
Defensive Security BLUE · 02 · 03

Forensics basics

Evidence is only as good as how you handled it. Collect volatile data before it evaporates, hash and log every artifact for chain of custody, extract IOCs, and stitch a timeline that turns scattered logs into a defensible story.

BLUE Middle ◷ 15 min
Level
FoundationsJuniorMiddleSenior

3 a.m. page: a payments pod is making outbound connections to an IP nobody recognizes. Your first instinct — the wrong one — is to SSH in and start grep-ing through logs to see what’s happening. You just wrote to the filesystem, bumped the access time on every file you cat-ed, and spawned processes that overwrote pages of RAM that held the attacker’s now-vanished reverse shell. The intrusion is still there; the evidence of how it got in just got quieter. Forensics is the discipline of answering “what happened, how, and can we prove it” — and almost every fatal mistake is made in the first ten minutes, by a well-meaning engineer touching the wrong thing first.

By the end of this lesson you’ll know the order to collect evidence in, how chain of custody keeps it trustworthy, what an IOC is, and how a timeline turns a pile of artifacts into a story you can defend.

Order of volatility: collect the fragile stuff first

The single most important rule in evidence collection is order of volatility: capture the data that disappears fastest, first. RAM is gone the instant the box reboots or the pod is rescheduled. Network connection state, running processes, and open file handles vanish within seconds to minutes. Disk survives a reboot; an off-site log or backup survives the disk. So you collect up the volatility ladder — memory before disk, live state before stored state — because every minute you spend on the durable stuff is a minute the fragile stuff is decaying.

This is exactly why “just SSH in and look around” is so destructive. Reading files updates access timestamps. Running tools allocates memory, overwriting the unallocated RAM where deleted-but-not-yet-reclaimed artifacts (an attacker’s in-memory payload, a freed buffer with a credential) still live. Every command is an observer effect: the act of looking changes what you can later prove. The senior move is the opposite reflex — acquire before you analyze. Snapshot the volatile state to somewhere else, then do your poking on the copy.

In cloud and Kubernetes the rule still holds, the mechanics just shift. You don’t image a physical disk; you snapshot the EBS volume, dump the container’s memory via the node before the pod is killed, and — critically — set the compromised instance’s auto-scaling and restart policy to not terminate it, because a rescheduled pod is a wiped crime scene. Cordon the node, snapshot, then investigate the snapshot.

Chain of custody: evidence you can defend

An artifact is only as trustworthy as the record of who touched it and when. Chain of custody is the unbroken, documented trail proving an artifact wasn’t altered between collection and conclusion: who collected it, when, with what tool, where it was stored, and every hand it passed through. The technical anchor is a cryptographic hash — you SHA-256 the memory dump or disk image at acquisition, write that hash down, and anyone can re-hash the copy later and confirm it matches bit-for-bit. A broken hash means the evidence was modified; a matching hash means it’s pristine.

The discipline that protects the hash is work on copies, never originals. Image the disk, hash the image, then do all analysis against a mounted read-only copy. The original (the snapshot, the sealed image) never gets touched again. This isn’t bureaucratic theater — if the incident becomes a legal matter, a regulatory disclosure, or even just an internal dispute about blame, evidence with a broken or missing custody chain is worthless. You’ll know what happened and be unable to prove it, which in a breach-notification or insurance context is the same as not knowing.

ArtifactVolatilityWhat it tells youCollection note
RAM / process memorySeconds — gone on rebootIn-memory payloads, decrypted keys, live shellsDump first; never reboot the box
Network + process stateSeconds–minutesC2 connections, listening ports, parent PIDsCapture before killing the pod
Disk imageSurvives rebootDropped files, persistence, deleted artifactsSnapshot, hash, mount read-only
Off-host logsDurable (if shipped)Auth events, API calls, the timeline spineAttacker can’t edit what already left the host

IOCs: the fingerprints you search for and share

An Indicator of Compromise (IOC) is an observable artifact that signals an intrusion: a malicious IP or domain, a file hash, a suspicious registry key or cron entry, a user-agent string, a mutex name. IOCs do two jobs. First, scoping: once you have one — say the SHA-256 of a dropped binary — you sweep every host for that hash to find the full blast radius, not just the box that paged you. Second, sharing: IOCs are the lingua franca of threat intel, so an IP you extract can be fed to detection rules and shared with peers.

The senior caveat: IOCs sit at the bottom of the Pyramid of Pain. Hashes and IPs are trivial for an attacker to change — a recompile gives a new hash, a new VPS gives a new IP. They’re cheap to collect and cheap to evade. The durable signal is higher up: TTPs — the tactics, techniques, and procedures the adversary uses, the thing MITRE ATT&CK catalogs. Mapping your findings to an ATT&CK technique (say T1059, command-and-scripting interpreter) survives the attacker swapping infrastructure, because changing how they operate is genuinely expensive. So extract IOCs to scope this incident, but reach for the behavior to build detection that catches the next one.

Why this works

Why hash the disk image before you do anything with it, instead of just trusting your own copy? Because the value of evidence is in being able to prove it’s unchanged, and you can only prove that against a number recorded at the moment of acquisition. If you analyze first and hash later, your hash certifies a possibly-already-mutated file — it proves nothing about the original state. The hash is a seal applied at collection time; apply it late and the seal is meaningless. This is the same logic as signing a contract before edits, not after.

The timeline: turning artifacts into a story

A pile of artifacts isn’t an answer. The deliverable of forensics is a timeline: a single, time-ordered sequence that fuses events from every source — auth logs, process-creation events, file modification times (the MAC times: modified, accessed, changed/created), network connections, deploy logs — into one narrative of what the attacker did, in order. This is where supertimelining tools earn their keep: they normalize timestamps from dozens of artifact types onto one axis so you can read the intrusion top to bottom.

The two hard problems are time and gaps. Time: correlating across sources demands a common reference — normalize everything to UTC, and watch for clock skew between hosts and for an attacker who tampered with timestamps to hide (timestomping; a file whose modified time predates its inode-change time is a tell). Gaps: the absence of a log is itself evidence — a deleted shell-history file or a window where audit logging was off tells you where the attacker worked and that they tried to cover it. A good timeline doesn’t just say what happened; lined up against MITRE ATT&CK it shows the progression — initial access, execution, persistence, lateral movement — and that progression is what tells you whether you’ve actually scoped the whole intrusion or only seen its tail.

Pick the best fit

A production pod is compromised and actively beaconing out. You need to investigate. What do you do first?

Quiz

Why is RAM collected before the disk image during evidence acquisition?

Quiz

You extract the IP and file hash of an attacker's tool. Why isn't building detection solely on those the strongest move?

Order the steps

Order an evidence-collection sequence correctly, from first to last:

  1. 1 Dump process / system memory (lost on reboot)
  2. 2 Capture live network connections and running processes
  3. 3 Snapshot and image the disk (survives reboot)
  4. 4 Collect durable off-host logs already shipped away
  5. 5 Hash each artifact and record the chain of custody
Recall before you leave
  1. 01
    Explain order of volatility and why 'just SSH in and look around' corrupts evidence.
  2. 02
    What is chain of custody, how does hashing enforce it, and why does it matter when the incident is over?
Recap

Forensics answers “what happened, how, and can we prove it” — and most fatal errors happen in the first ten minutes when a well-meaning engineer touches the wrong thing. The discipline is acquire-before-analyze, ordered by volatility: dump memory before it’s lost to a reboot or reschedule, capture live network and process state, snapshot the disk, and pull durable off-host logs that the attacker can’t edit. Every artifact is SHA-256 hashed at collection and analyzed only as a read-only copy, so chain of custody — the documented trail of who touched what, when — stays unbroken and the evidence is defensible if the incident turns legal or regulatory. IOCs (IPs, hashes, domains) let you sweep every host to scope the blast radius and feed detection, but they sit at the bottom of the Pyramid of Pain and are trivial to rotate, so map findings to durable TTPs in MITRE ATT&CK too. Finally, fuse it all into a UTC-normalized timeline: correlate across sources, watch for clock skew and timestomping, treat missing logs as evidence of where the attacker worked, and read the progression against ATT&CK to confirm you’ve scoped the whole intrusion, not just its tail. Next time you’re paged, your first move isn’t to look — it’s to acquire.

Practice

Start at the top. Tasks go easiest → hardest: recall a fact, apply it to a case, then a senior-level stretch. Open one, attempt it, then reveal.

recallapplystretch0 of 6 done
Connected lessons

Something unclear?

Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.

shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.