Incident response basics

Introduction

No defence is perfect, so every organisation will one day have an incident: a stolen password used to log in, malware on a lab PC, a database copied out. What happens in the first hours decides whether it becomes a small story or a disaster. Incident response is the plan for those hours, written before they arrive.

A university that has a plan knows who to call, which systems to cut off, how to keep evidence, and what to tell students. One without a plan argues about it while the attacker keeps working.

How it works

The widely used US guide NIST SP 800-61 describes four phases, in a loop:

  1. Preparation: a written plan, a team with named roles, contact lists, logs that are actually kept, and practice drills.
  2. Detection and analysis: noticing that something is wrong (an alert, a user's report), confirming it is real, and working out what happened and how serious it is.
  3. Containment, eradication and recovery: stop the spread (isolate a machine, disable an account), remove the cause (malware, the attacker's access), and restore normal service from clean backups.
  4. Post-incident activity: a blameless review of what happened, what worked, and what to change, so it does not happen the same way again.

Two numbers show how well this works. Time to detect is how long the attacker was inside before anyone noticed; time to contain is how long after that until they were stopped. Good logging shrinks the first; good preparation shrinks the second.

Triage decides what to handle first. A common way is to score impact (how much harm) and urgency (how fast it spreads) and handle the highest first, just like the risk matrix earlier in the course.

Example

During analysis, the team builds a timeline from logs and reports, which usually arrive out of order. The program sorts the events and measures the two times.

// Building an incident timeline: put the events in order, then measure how long each phase took.
const events = [
  { min: 95, what: "server isolated from the network (contained)" },
  { min: 0, what: "phishing email opened, password entered" },
  { min: 70, what: "alert: login from a new country (detected)" },
  { min: 12, what: "attacker logs in with the stolen password" },
  { min: 40, what: "attacker copies the grades spreadsheet" },
];

events.sort((a, b) => a.min - b.min);
for (const e of events) console.log("min " + String(e.min).padStart(3) + "  " + e.what);

const start = events[0].min;
const detected = events.find((e) => e.what.includes("detected")).min;
const contained = events.find((e) => e.what.includes("contained")).min;
console.log("time to detect: " + (detected - start) + " min, time to contain after detection: " + (contained - detected) + " min");
Open in compiler

Line by line

  1. Each event has the minute it happened and a short description. They arrive in the order they were found, not the order they happened.
  2. sort puts them in time order, which is the timeline.
  3. The first event, the phishing email at minute 0, is the start of the incident.
  4. The alert at minute 70 is detection, so the time to detect is 70 minutes, and the attacker had already copied the spreadsheet at minute 40.
  5. Isolation at minute 95 is containment, 25 minutes after detection.

Expected result

min   0  phishing email opened, password entered
min  12  attacker logs in with the stolen password
min  40  attacker copies the grades spreadsheet
min  70  alert: login from a new country (detected)
min  95  server isolated from the network (contained)
time to detect: 70 min, time to contain after detection: 25 min

The timeline already suggests improvements for the review: an alert on the first strange login (minute 12) instead of the second, and a second factor that would have made the stolen password useless.

In the real world

  • Many countries require organisations to report certain breaches of personal data to an authority, and sometimes to the people affected, within a fixed time; the plan should say who does that.
  • Evidence matters: logs and disk images are copied before machines are wiped, in case they are needed later.
  • Ransomware response depends on backups that the attacker could not reach, which is why offline or separate backups are part of preparation.
  • Large organisations have a Security Operations Centre (SOC) that watches alerts all day; small ones often contract this out.

Common mistakes

  • No written plan, so the first hour is spent deciding who is in charge.
  • Wiping a machine before saving evidence, which loses what happened.
  • Restoring from backups that are also infected.
  • Blaming the person who clicked, which teaches everyone to hide mistakes next time.

Best practices

  • Write the plan, name the roles, and practise it with a drill at least once a year.
  • Keep logs long enough to look back, and in a place an attacker cannot easily change.
  • Contain first, then investigate, then recover from known-clean backups.
  • Hold a blameless review and turn its lessons into concrete changes.

Summary

Incident response is the prepared plan for when a defence fails. NIST SP 800-61 describes four phases: preparation; detection and analysis; containment, eradication and recovery; and post-incident activity. A timeline built from logs shows what happened and gives the time to detect and the time to contain, the two numbers good logging and preparation shrink. Saving evidence, clean backups and blameless reviews turn each incident into a lesson instead of a repeat.

Quick check

1. Which phase includes writing the plan and running drills?
2. An attacker entered at 09:00, the alert fired at 13:00 and the machine was isolated at 13:30. What is the time to detect?
3. A lab PC has malware. What should happen before it is wiped?
4. Why should the post-incident review be blameless?

Key takeaways

  • Prepare before incidents: a plan, roles, logs and drills.
  • Contain first, save evidence, then recover from clean backups.
  • A timeline gives time to detect and time to contain; both should shrink.
  • Blameless reviews turn incidents into improvements.

Practice problems for this lesson

Was this lesson clear?

My notes

Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.