When something has already gone wrong
Incident against breach, why you cannot respond to what you never noticed, containment before eradication, why restoring from backup is not always the answer, evidence you destroy by rebooting, and post-mortems that do not look for someone to blame.
Everything so far has been about preventing things. This lesson is about the other half, which is what separates a security hobby from a security job: what happens between the moment something goes wrong and the moment it is over. It is a process lesson more than a technical one, and the process is the part that fails most often under pressure, because the correct action is frequently the one that feels least decisive. A post-mortem is the part of the process that makes the next incident cheaper, and it only works if people tell the truth. Blame and truth are in direct competition: the first question of an investigation that is looking for a culprit is whether anyone will volunteer information afterwards. The substitute for blame is not vagueness, it is a different question. Instead of asking who ran the wrong command, ask what made the wrong command look right, and what would have made the wrong outcome impossible rather than merely discouraged. An action item that says be more careful is not an action item. An action item that says the deploy script now refuses to run against production without an explicit confirmation flag is one, because it does not depend on anyone remembering anything. The same incident written up twice. Only the second version produces action items that survive contact with a busy week. The honest summary is that prevention and response fail in different ways. Prevention fails because a control you believed in did not hold, and it usually fails quietly. Response fails because of the things humans do under pressure, and it fails loudly: rebooting the machine that held the evidence, wiping the host because the symptoms stopped, restoring a backup taken after the intrusion began, or writing a report that ensures nobody reports the next one. The uncomfortable conclusion is that the outcome of an incident is decided less by the sophistication of the attacker than by whether the organisation had written down, and practised, what it would do.
The first and hardest stage is noticing. An event is anything observable; an alert is an event someone decided was worth attention; an incident is an alert someone decided was real. Each of those conversions can fail. Logs that are never reviewed are decoration. Alerts that fire four thousand times a day train everyone to ignore them, which is worse than having no alert at all, because it also removes the assumption that somebody is watching. The practical lesson is that detection capacity is not the number of tools but the number of signals a human will actually look at. Everything downstream in this lesson is unavailable to an organisation that has not solved this stage, because you cannot contain what you have not noticed. Rough industry picture of how long breaches go unnoticed. The variation between organisations is far larger than the variation between years. An alert needs three things to be useful: a description of what was observed, enough context to judge it, and a defined action. An alert that says only that something anomalous happened is worse than silence, because it costs attention and returns nothing. The baseline is what makes context possible. You cannot say a login at 03:14 is unusual unless you know what a normal hour looks like for that account, which means the useful work starts long before the incident, when somebody decides what to record.
$ sudo dd if=/dev/sda1 of=/mnt/evidence/disk.img bs=4M conv=noerror,sync
$ sha256sum /mnt/evidence/disk.img | tee /mnt/evidence/disk.img.sha256
$ date -u +"%Y-%m-%dT%H:%M:%SZ" | tee -a /mnt/evidence/chain-of-custody.txt
# every later look works on a copy, never on the original
$ cp /mnt/evidence/disk.img /tmp/work.imgCapturing a disk image and starting a chain of custody. The hash is the point: it is what lets you say later that the copy was not altered.An incident is an event that threatens or violates policy, confidentiality, integrity or availability. A breach is a specific kind of incident: one where data was actually accessed or taken by someone who should not have had it. The distinction is not pedantry, it changes what you do. A phishing campaign that nobody clicked is an incident with no breach, and the response is to block the sender and warn people. A misconfigured bucket that was public for a week is potentially a breach even though nothing technical broke, and the response involves finding out whether anyone read it. Collapsing the two makes organisations either overreact to noise or underreact to a real exposure.
Containment stops the damage. Eradication removes the cause. Restoration puts the service back. These are three different goals and they are frequently run as one, which is where the trouble starts. The instinct under pressure is to reboot, reinstall and restore, because that makes the symptoms go away. A rebuild that starts before you understand how the attacker got in produces a machine that is clean and a mystery that is permanent, and if the entry path was not closed, the next build is compromised in the same way. The order matters, and so does the willingness to keep a compromised machine isolated and running for a while rather than wiping it immediately. The three stages and the action each one is allowed to take. Notice that preservation happens inside containment, before eradication wipes the machine. Restoring from backup is an excellent answer to a hardware failure and a dangerous answer to an intrusion. The question that decides it is not how good the backup is, but when the attacker arrived relative to when the backup was taken. If the backup was made after the intrusion began, whatever persistence mechanism was installed may still be in it, and you will restore the compromise along with the data. This is the reason that containment comes before restoration: you need enough understanding of the timeline to pick a restore point that predates the first sign of entry, and you need to have closed the entry path before you bring anything back online. Evidence has a lifetime, and it runs out in the opposite order from what most people expect. Anything in memory, in a running process, in a network connection or in a temporary file is gone the moment the machine loses power or reboots. Anything on disk survives a reboot but not a reinstall. Anything in a central log store survives both, if it was already shipped there, which is why centralised logging is a forensic control and not just an operational convenience. The first actions of a response are therefore almost mechanical: note the current time, capture what is volatile before it disappears, and only then start deciding what to do about the machine. The rule that follows from this is short and is the one people break most often in the first five minutes: do not reboot. A reboot clears memory, drops network connections, stops running processes and overwrites part of the state you needed, and the attacker may have left a startup entry that the reboot triggers. If the machine must be isolated, unplug the network rather than the power. This is unintuitive precisely because turning it off and on again is the correct answer to almost every other problem a computer has.
Practice
A server is confirmed compromised. The team wants to rebuild it from a known-good image immediately to stop the attack. What is the main reason to delay the rebuild?
Hints
- Ask what each action does to the evidence. Anything that clears memory or overwrites state destroys the only record of how the attacker got in.
- Reinstalling feels decisive, but it answers the wrong question. You already know the service is broken; what you do not know is why.
Put the incident response stages in order.
- 1eradicate: close the entry path and remove whatever the attacker left behind
- 2detect: something is observed and someone decides it is a real incident
- 3contain: isolate the affected systems and revoke the credentials that were used
- 4preserve: capture memory and the current state before anything changes it
- 5review: write down what happened and what would have caught it earlier
- 6restore: bring the service back from a point known to predate the intrusion
Hints
- The very first step is not technical at all: somebody has to notice, and somebody has to be told.
- Stopping the spread comes before removing the cause, and both come before rebuilding anything, because a rebuild that starts too early throws away the answer.
Match each kind of evidence to how long it survives and what destroys it.
Hints
- Sort by how long the thing survives. Registers and process memory are gone the moment power is cut, and a file on disk can wait.
- For each item ask whether a reboot or a reinstall would destroy it. Everything that would is gathered first.
Questions about this lesson
Is it free?
Yes. The first level of every subject is free and needs no account. Deeper levels and the senior grades are paid — that is what keeps the project running.
What age is this for?
It is written for curious teenagers from about 12 and for adults starting from zero. Nothing assumes prior programming experience; lessons about networking and physics need no mathematics beyond school level.
Do I need to know programming already?
No. The logic, physics and networking tracks start from nothing. The languages track is where you actually write code, and it also starts from the beginning.
Do I need to install anything?
No. Everything runs in the browser: theory, practice and the interactive simulations. There is nothing to download and no environment to configure.
How long does one subject take?
A lesson takes 10 to 15 minutes. A junior grade is roughly 12 to 20 lessons, so expect a few weeks of steady practice rather than one evening.
Do I have to follow the order?
Within a grade, levels open one after another, because each builds on the previous one. Between subjects you are free: start with logic, physics or networking.