SyntaxPilot
Courses/Cybersecurity Fundamentals/Lesson 75
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Cybersecurity Fundamentals · Lesson 75 of 90

Incident response

security event vs incidentNIST SP 800-61 lifecycle (preparation, detection and analysis, containment, eradication, recovery, post-incident activity)SANS PICERLincident response planCSIRTseverity levelscommunications and legalevidence preservationlessons learnedblameless post-mortemtabletop exercisesCERT-In 6-hour incident reporting

These are the notes for Cybersecurity Fundamentals (defensive), episode 75. In episode 74 a threat hunt found an attacker inside. Now the hardest part: what do we actually do? Unplug everything? Wipe the server? Call the police? Tell customers? This episode invents incident response: the plan that turns panic into steps, in the right order. Every term is defined the first time it appears; the Glossary collects them.

Scope. Defensive and educational only. Every program is a toy simulation on made-up data; hosts and accounts are invented. Samples were run on 14 Nov 2026 in Python 3, the same code as in the SyntaxPilot compiler in the video. This is general education, not legal advice: check current rules with your legal team.

Two kitchens, one fire

Real-life example: two restaurant kitchens on a Saturday night, same accident: oil in a pan catches fire. Kitchen A panics; someone throws water on the oil and the fire spreads across the kitchen: fast action, wrong action. Kitchen B practised last month: one cook turns off the gas, another puts a lid on the pan, the manager moves guests out and calls the fire brigade on 101. Next morning they ask why it happened and fix the exhaust hood. A practised plan, followed in the right order, then learning: that is incident response.

  • Incident response (IR): the organised way an organisation prepares for, detects, contains, removes, recovers from and learns from security incidents.

Step 1: is it an incident?

Demo 1: events vs incidents

# Which of these are just EVENTS, and which are INCIDENTS?
events = [("ravi mistyped his password once",                    False, False),
          ("port scan from the internet, firewall blocked it",   False, False),
          ("malware ran on the HR laptop",                       True,  False),
          ("customer list copied to an unknown server",          True,  False),
          ("employee emailed salary sheet to personal Gmail",    False, True)]
#                                   (harms C, I or A?)  (breaks policy?)
incidents = 0
for what, harm, policy in events:
    kind = "INCIDENT" if harm or policy else "event   "
    incidents += kind == "INCIDENT"
    print(f"{kind}  {what}")
print(f"{len(events)} events, {incidents} incidents")

Real output:

event     ravi mistyped his password once
event     port scan from the internet, firewall blocked it
INCIDENT  malware ran on the HR laptop
INCIDENT  customer list copied to an unknown server
INCIDENT  employee emailed salary sheet to personal Gmail
5 events, 3 incidents
  • Security event: anything observable that happens in a system or network: a login, a blocked scan, a file opened.
  • Security incident: an event (or series of events) that actually or likely harms the confidentiality, integrity or availability (the CIA triad, episode 2) of systems or data, or violates a security policy. The salary sheet emailed to a personal account harms nothing technical, but breaks policy and exposes data: an incident.
  • Every incident is an event; very few events are incidents.

Step 2: why panic fails, and the lifecycle

Demo 2: the panic response

# Panic response: 'just wipe the server and move on'.
server = {"malware": True, "backdoor_user": "support2", "logs": ["02:10 support2 created",
          "02:12 9,812 rows exported"], "stolen_password": "admin"}

def panic_fix(s):
    s["malware"] = False                     # reinstall the server ...
    s["logs"] = []                           # ... which also wiped the evidence
    return s

day = panic_fix(server)
print("day 1: malware gone?", not day["malware"])
print("day 1: what did they take? logs:", day["logs"] or "NOTHING LEFT TO READ")
print("day 3: attacker logs in with:", day["stolen_password"], "(password never reset)")
print("day 3: backdoor account still there:", day["backdoor_user"])
print("RESULT: attacker is back, and we can't say what was stolen")

Real output:

day 1: malware gone? True
day 1: what did they take? logs: NOTHING LEFT TO READ
day 3: attacker logs in with: admin (password never reset)
day 3: backdoor account still there: support2
RESULT: attacker is back, and we can't say what was stolen

Fast, but in the wrong order: nobody found out how far the attacker reached, nobody kept evidence, and nobody closed the way they got in (the stolen password, the backdoor account). Like water on an oil fire.

  • Backdoor: a hidden way back in that an attacker leaves behind, such as an extra account (support2).

NIST SP 800-61 and SANS PICERL

NIST (the US National Institute of Standards and Technology) published the classic incident handling guide, SP 800-61 Rev. 2 (August 2012), with a four-phase lifecycle:

1 preparation  →  2 detection and analysis  →  3 containment, eradication and recovery  →  4 post-incident activity
      ↑                                                                                              |
      └──────────────────────────── lessons learned feed back into preparation ───────────────────────┘

In April 2025 NIST published SP 800-61 Rev. 3, Incident Response Recommendations and Considerations for Cybersecurity Risk Management: A CSF 2.0 Community Profile, which supersedes Rev. 2. It places incident response inside the six functions of the NIST Cybersecurity Framework (CSF) 2.0 (Govern, Identify, Protect, Detect, Respond, Recover; episode 79): NIST says "the six Functions of the NIST Cybersecurity Framework (CSF) 2.0 all play vital roles in incident response." The practical steps on the day remain the same.

The SANS Institute teaches six steps, PICERL:

SANS step What it means NIST Rev. 2 phase
Preparation plan, team, tools, practice preparation
Identification is it real? how big? detection and analysis
Containment stop the spread containment, eradication and recovery
Eradication remove the attacker and their way in containment, eradication and recovery
Recovery restore and monitor containment, eradication and recovery
Lessons learned review and improve post-incident activity

Step 3: preparation

  • Incident response plan (IR plan): a written, approved document saying who does what, who may decide what (e.g. taking a service offline), how to classify incidents, and who to call: internal leaders, lawyers, the insurer, CERT-In, police, key vendors.
  • CSIRT (Computer Security Incident Response Team): the team named in the plan that handles incidents. Typical roles: incident lead (runs the response, keeps the timeline), technical responders (contain, analyse, eradicate), legal and communications (what is said, to whom, when), leaders (business decisions).
  • Prepare the boring things: an up-to-date contact list (also printed: during ransomware the network holding your plan may be down), logs that exist (episode 72), tested backups (episode 76), playbooks (episode 74), a report template, and a separate communication channel in case email is compromised.

Demo 3: severity levels

Severity levels: pre-agreed classes of how serious an incident is, and what each one triggers (who joins, how fast, how often to update). They prevent both panicking over small things and treating a real breach like a ticket.

# Severity levels: decide in minutes, not hours, how big this is.
def severity(data, users, critical_down):
    if critical_down or data == "personal data":
        return "SEV1", "all hands now, CISO + legal, hourly updates"
    if users > 100 or data == "internal":
        return "SEV2", "incident team now, updates every 4 hours"
    if users > 0:
        return "SEV3", "next business hours"
    return "SEV4", "normal ticket"

cases = [("customer list copied", "personal data", 9812, False),
         ("payroll server encrypted", "none", 0, True),
         ("malware on 1 laptop, isolated", "none", 1, False),
         ("phishing email, nobody clicked", "none", 0, False)]
for name, data, users, down in cases:
    level, action = severity(data, users, down)
    print(f"{level}  {name:31} {action}")

Real output:

SEV1  customer list copied            all hands now, CISO + legal, hourly updates
SEV1  payroll server encrypted        all hands now, CISO + legal, hourly updates
SEV3  malware on 1 laptop, isolated   next business hours
SEV4  phishing email, nobody clicked  normal ticket

The severity can go up or down as you learn more. Real plans also consider legal reporting duties, number of customers affected, and whether the attacker is still active.

Step 4: analysis, containment, evidence

Demo 4: scoping

Scoping: working out how far an incident reaches: every host, account and data set the attacker touched.

# Detection and analysis: what ELSE did the attacker touch? (scoping)
logins = [("02:10", "support2", "web-01"), ("02:14", "support2", "db-01"),
          ("02:20", "ravi",     "web-01"), ("02:31", "support2", "backup-01"),
          ("02:40", "neha",     "mail-01"), ("03:02", "support2", "hr-laptop-7")]
bad = "support2"

touched = []
for t, user, host in logins:
    if user == bad and host not in touched: touched.append(host)
print("we knew about:   web-01")
print("attacker touched:", ", ".join(touched))
print(f"scope = {len(touched)} hosts, not 1. Contain ALL of them, or they come back.")

Real output:

we knew about:   web-01
attacker touched: web-01, db-01, backup-01, hr-laptop-7
scope = 4 hosts, not 1. Contain ALL of them, or they come back.

Detection and analysis also builds a timeline (the list of what happened, in order, from the logs) and answers: how did they get in, what did they take, are they still here? Write every action down with its time: those notes become the incident report.

Containment

  • Containment: stopping the damage from growing.
  • Short-term containment: isolate affected hosts from the network (EDR "network isolation", unplugging the network cable, a firewall rule), disable compromised accounts, revoke sessions.
  • Long-term containment: block attacker addresses, separate network segments, extra monitoring, temporary fixes while you prepare a clean rebuild.
  • Isolate, don't power off: memory (RAM) holds evidence, such as running malware and network connections, that disappears when power is cut.
  • Contain all scoped hosts at the same time, or the attacker hops to the one you left.
  • Weigh business impact: taking payments offline also hurts; that is why leaders are part of the plan.

Demo 5: evidence preservation and chain of custody

# Evidence preservation: hash the copy as soon as it is taken, then log who handled it.
from hashlib import sha256
from datetime import datetime, timezone
evidence = b"web-01 disk image (toy): logs, support2 created, 9,812 rows exported"
taken = sha256(evidence).hexdigest()
custody = [(datetime(2026, 11, 14, 4, 5, tzinfo=timezone.utc), "asha", "copied disk image"),
           (datetime(2026, 11, 14, 6, 30, tzinfo=timezone.utc), "ravi", "received for analysis")]

print("hash when taken:", taken[:24])
for when, who, what in custody: print(f"   {when:%Y-%m-%d %H:%MZ}  {who:5} {what}")

later = evidence.replace(b"9,812", b"98")              # someone 'tidies' the copy
print("hash in court  :", sha256(later).hexdigest()[:24])
print("evidence intact?", sha256(later).hexdigest() == taken)

Real output:

hash when taken: a0694fff777c8b2932673a33
   2026-11-14 04:05Z  asha  copied disk image
   2026-11-14 06:30Z  ravi  received for analysis
hash in court  : 4c6630e6c1eee4ec791d3674
evidence intact? False
  • Evidence preservation: collecting copies of logs, disk images and memory without changing them, and proving it, for example with a cryptographic hash (episode 13) taken at collection time.
  • Disk image: an exact, bit-for-bit copy of a storage device.
  • Chain of custody: a record of every person who handled the evidence, when and why, from collection onward. If it is broken, the evidence may not be accepted by a court or regulator. Episode 77 (digital forensics) goes deeper.

Step 5: eradication, then recovery

Demo 6: the right order

# Contain -> eradicate -> recover, in the RIGHT order.
s = {"isolated": False, "backdoor_user": "support2", "admin_password_reset": False,
     "patched": False, "restored_from": None, "monitoring": False}
steps = [("contain",   "isolate web-01 from the network",     lambda: s.update(isolated=True)),
         ("eradicate", "delete backdoor account support2",    lambda: s.update(backdoor_user=None)),
         ("eradicate", "reset every stolen password",         lambda: s.update(admin_password_reset=True)),
         ("eradicate", "patch the hole they came in through", lambda: s.update(patched=True)),
         ("recover",   "restore from the clean 12 Nov backup", lambda: s.update(restored_from="12 Nov")),
         ("recover",   "reconnect, watch closely for 30 days", lambda: s.update(monitoring=True))]
for phase, what, do in steps:
    do(); print(f"{phase:9}  {what}")

back = s["backdoor_user"] or not s["admin_password_reset"] or not s["patched"]
print("day 3: attacker gets back in?", back)

Real output:

contain    isolate web-01 from the network
eradicate  delete backdoor account support2
eradicate  reset every stolen password
eradicate  patch the hole they came in through
recover    restore from the clean 12 Nov backup
recover    reconnect, watch closely for 30 days
day 3: attacker gets back in? False
  • Eradication: removing every trace of the attacker and their way in: malware, backdoor accounts, persistence (episode 74), stolen credentials (reset them all), and the vulnerability they used (patch it).
  • Recovery: bringing systems back to normal operation, ideally rebuilt or restored from a clean backup made before the attack, then reconnecting and monitoring closely for the attacker's return.
  • Skip eradication and recovery just reopens the door.

Step 6: tell, then learn

Demo 7: who must we tell, and by when?

# Who must we tell, and by when? CERT-In: report within 6 hours of noticing.
from datetime import datetime, timedelta
noticed = datetime(2026, 11, 14, 23, 10)               # Saturday night, IST

deadlines = [("CERT-In report",          timedelta(hours=6)),
             ("internal: CISO + legal",  timedelta(minutes=30)),
             ("cyber insurer (contract)", timedelta(hours=24))]
print("noticed at:", noticed.strftime("%a %d %b %H:%M"))
for who, within in sorted(deadlines, key=lambda d: d[1]):
    print(f"   {who:25} by {(noticed + within):%a %d %b %H:%M}")
print("data of customers involved? -> also the DPDP Act duties (episode 81)")

Real output:

noticed at: Sat 14 Nov 23:10
   internal: CISO + legal    by Sat 14 Nov 23:40
   CERT-In report            by Sun 15 Nov 05:10
   cyber insurer (contract)  by Sun 15 Nov 23:10
data of customers involved? -> also the DPDP Act duties (episode 81)
  • CERT-In (the Indian Computer Emergency Response Team) Directions of 28 April 2022: organisations must report cyber incidents to CERT-In within six hours of noticing them or being told about them. Reportable types include data breaches and data leaks, attacks on IoT devices, digital payment systems, cloud services, malicious mobile apps, unauthorised access to social media accounts, and attacks on AI/ML systems. The same directions require ICT logs to be kept for a rolling 180 days in India and clocks synchronised to NIC or NPL NTP servers (episode 72).
  • If personal data is involved, the DPDP Act (India's Digital Personal Data Protection Act, episode 81) adds duties to inform the Data Protection Board and affected people.
  • Communications and legal: decide in advance who may speak to staff, customers, regulators and the press; say only facts legal has checked; no guesses, no blame, and never "all is fine" before you know. Contracts (insurers, customers, cloud providers) may impose their own deadlines.

Lessons learned, blameless post-mortems, tabletop exercises

  • Lessons learned: a meeting soon after the incident is closed: what happened, what worked, what did not, what will change. The written record is the post-mortem (also called the incident review).
  • Blameless post-mortem: a review that looks for what in the system allowed the mistake, not who to punish. Not "Ravi clicked a link" but "why could one click reach the payroll server?". Blame makes people hide mistakes; blameless reviews make them report early. Every finding gets an owner and a due date.
  • Tabletop exercise: a rehearsal where the team sits around a table and talks through a made-up incident, step by step, as a facilitator adds new developments ("it is Saturday night, payroll is encrypted, the attacker emails a ransom demand"). Gaps in the plan show up in a meeting room, not in a real crisis. Run them regularly and update the plan each time.

The whole chain

  1. Is it serious? → event vs incident.
  2. Wipe-and-pray fails → NIST SP 800-61 lifecycle, SANS PICERL.
  3. Who does what? → IR plan, CSIRT, severity levels.
  4. One host known, four touched → scoping, containment.
  5. A "tidied" copy → evidence preservation, hashes, chain of custody.
  6. Attacker back on day 3 → eradicate, then recover.
  7. Tell and learn → CERT-In 6 hours, communications and legal, blameless post-mortem, tabletop exercises.

Common mistakes (and the fix)

Mistake What you see Why Fix
wipe the server at once logs: NOTHING LEFT TO READ evidence destroyed before analysis isolate, collect, hash, then clean
power off the machine malware in memory lost RAM evidence vanishes isolate from the network, keep it running for collection
clean only the known host attacker touched: web-01, db-01, backup-01, hr-laptop-7 no scoping scope from logs, contain everything at once
restore without eradication day 3: attacker logs in with: admin stolen password, backdoor remain reset credentials, remove backdoors, patch
edit the evidence copy evidence intact? False hash no longer matches work on a copy of the copy; log custody
"we'll report on Monday" CERT-In six-hour window missed no contacts or template ready contacts and report draft prepared in the plan
blame the clicker people hide the next mistake fear blameless post-mortem, fix the system
plan never practised nobody knows the CSIRT on the day plan only on paper tabletop exercises, regularly

Mini project: an incident logbook

Write a small program that an incident lead could use: (1) record events with UTC timestamps and the person acting, (2) classify severity from a few questions, (3) list scoped hosts and mark each contained / eradicated / recovered, (4) hash every evidence file as it is added and keep a chain-of-custody log, (5) compute the CERT-In reporting deadline from the "noticed at" time, and (6) print a post-mortem skeleton with timeline, root cause, what worked, what did not, and action items with owners.

Practice

1. Add "ransomware note found" to the severity toy as SEV1.

Solution
def severity(data, users, critical_down, ransom_note=False):
    if critical_down or ransom_note or data == "personal data":
        return "SEV1", "all hands now, CISO + legal, hourly updates"
    ...
print(severity("none", 0, False, ransom_note=True))
# ('SEV1', 'all hands now, CISO + legal, hourly updates')

2. Make the scoping toy also list the accounts that logged in to those hosts.

Solution
others = sorted({u for t, u, h in logins if h in touched and u != bad})
print("other accounts on those hosts:", others)
# other accounts on those hosts: ['ravi']   (check: was ravi's password also stolen?)

3. Event or incident? (a) 300 failed logins blocked by lockout; (b) an admin account created at 3 a.m. by an unknown process; (c) a laptop with an encrypted disk lost on a train.

Answer(a) event (worth watching; becomes an incident if one succeeds), (b) incident (likely compromise, harms integrity), (c) incident by most policies (lost asset), usually low severity because the disk is encrypted: still revoke its sessions.

4. Write a one-page IR contact list for a small shop.

SolutionIncident lead (owner) and deputy; IT support company (24×7 number); bank and payment provider fraud lines; cyber insurer and policy number; lawyer; CERT-In reporting contact (from cert-in.org.in); police cyber cell and 1930 helpline; key vendors (website host, email provider). Print it and keep it offline.

5. Run a 30-minute tabletop.

Example scriptInject 1 (0 min): "Customers say the website shows a ransom note." Inject 2 (10 min): "The admin password was found on a paste site." Inject 3 (20 min): "A journalist calls." At each inject ask: who decides, what do we do first, who do we tell, what evidence do we keep? Write down every gap and fix one this week.

Quick quiz

A: wipe and reinstall the server
B: isolate it from the network and preserve evidence
C: post about it on social media
D: restore last month's backup straight away

Malware is found on a server. What should come FIRST?

Answer

B. Contain it (isolate) and preserve evidence first. Wiping or restoring comes later, after scoping and eradication; restoring first can bring the attacker straight back, and wiping destroys the evidence.

Interview questions

  1. Event vs incident? An event is any observable occurrence; an incident is an event that actually or likely harms confidentiality, integrity or availability, or violates policy.
  2. Name the NIST SP 800-61 lifecycle phases. Rev. 2: preparation; detection and analysis; containment, eradication and recovery; post-incident activity. Rev. 3 (April 2025) supersedes it and aligns IR with CSF 2.0's six functions.
  3. What does PICERL stand for? Preparation, Identification, Containment, Eradication, Recovery, Lessons learned (SANS).
  4. What goes in an IR plan? Scope, roles (CSIRT), decision authority, severity levels, contacts, communication rules, legal/reporting duties, playbooks, evidence handling, review process.
  5. Why isolate instead of powering off? Volatile memory holds evidence lost at power-off; isolation stops spread while preserving it.
  6. What is chain of custody? A documented record of who handled evidence, when and why, from collection to court; with hashes, it proves integrity.
  7. Why must eradication come before recovery? Otherwise backdoors, stolen credentials and the original vulnerability let the attacker straight back in.
  8. What is the CERT-In reporting rule? Report cyber incidents to CERT-In within six hours of noticing or being notified (Directions of 28 April 2022).
  9. What is a blameless post-mortem? A review focused on system causes and improvements, not individual blame, so people report problems openly.
  10. What is a tabletop exercise? A discussion-based rehearsal of a simulated incident to test the plan, roles and decisions.
  11. How do you decide severity? By impact on data and services, number of users, criticality, legal duties and whether the attack is ongoing, using pre-agreed levels.

Glossary

Term Meaning
incident response (IR) the organised way to prepare for, handle and learn from security incidents
security event any observable occurrence in a system or network
security incident an event that actually or likely harms C, I or A, or violates policy
CIA triad confidentiality, integrity, availability
backdoor a hidden way back in left by an attacker
NIST the US National Institute of Standards and Technology
SP 800-61 NIST's incident response guide (Rev. 2 2012; Rev. 3 April 2025)
CSF 2.0 NIST Cybersecurity Framework 2.0: Govern, Identify, Protect, Detect, Respond, Recover
preparation getting the plan, team, tools and practice ready before an incident
detection and analysis confirming an incident and working out what happened and how far it reached
post-incident activity reviewing the incident and improving
SANS PICERL Preparation, Identification, Containment, Eradication, Recovery, Lessons learned
IR plan the written plan: roles, decisions, severity, contacts, communications
CSIRT Computer Security Incident Response Team
incident lead the person who runs the response and keeps the timeline
severity level a pre-agreed class of how serious an incident is and what it triggers
scoping finding every host, account and data set an incident touched
timeline the list of what happened, in order, with times
containment stopping the damage from growing (short-term and long-term)
isolation cutting a machine off from the network while keeping it running
evidence preservation collecting logs, disks and memory without changing them, proven with hashes
disk image an exact bit-for-bit copy of a storage device
hash a fingerprint of data; any change gives a different hash
chain of custody a record of who handled evidence, when and why
eradication removing malware, backdoors, stolen credentials and the original weakness
recovery restoring normal operation from clean sources and monitoring
clean backup a backup made before the attack began
CERT-In the Indian Computer Emergency Response Team, the national incident agency
six-hour reporting CERT-In's rule to report cyber incidents within six hours of noticing
DPDP Act India's Digital Personal Data Protection Act, 2023
communications who says what, to whom, when, during an incident
lessons learned the review of what worked, what did not and what will change
post-mortem the written incident review
blameless post-mortem a review that fixes system causes instead of blaming people
tabletop exercise a discussion-based rehearsal of a made-up incident
inject a new development a facilitator adds during a tabletop

Summary

  • An incident is an event that harms C, I or A or breaks policy; most events are not incidents.
  • Follow the lifecycle (NIST SP 800-61, SANS PICERL): prepare, detect and analyse, contain, eradicate, recover, learn.
  • Prepare: an IR plan, a CSIRT, severity levels, contacts on paper.
  • Scope before you clean; contain everything at once; isolate, don't power off.
  • Preserve evidence with hashes and a chain of custody; eradicate, then recover.
  • Report to CERT-In within six hours, speak with one voice, and learn through blameless post-mortems and tabletop exercises.
  • Next episode: ransomware readiness, backups and business continuity.

Sources (fetched 14 Nov 2026)

  • NIST CSRC, SP 800-61 Rev. 3 (April 2025, supersedes Rev. 2): https://csrc.nist.gov/pubs/sp/800/61/r3/final
  • NIST news, NIST revises SP 800-61: https://nist.gov/news-events/news/2025/04/nist-revises-sp-800-61-incident-response-recommendations-and-considerations
  • Security Scientist, SANS incident response phases (PICERL): https://www.securityscientist.net/blog/12-questions-and-answers-about-sans-incident-response-phases/
  • The Current India, government helpline numbers (fire 101, cyber crime 1930): https://www.thecurrentindia.com/govt/government-helpline-numbers-india/
  • Trilegal, 2022 CERT-In directions on reporting cyber incidents: https://trilegal.com/knowledge_repository/2022-cert-in-directions-on-reporting-cyber-incidents/