In this section

0.9 Response and Detection Basics

Module 0

Introduction

Investigation leads to decisions: contain this machine, reset that account, rebuild the server, change the rule that missed it. Those decisions belong to incident response, and the last one, improving detection, is how an organization gets better at noticing the next incident. Module 9 covers both: responding to a developing incident and improving one detection.

This lesson lays the ground. It sets out the response model in NIST's current incident response guidance, records a short response stage by stage, takes a detection rule apart into its components, and writes one rule's logic three ways before running it against a real recording. The last section shows the most common way a new rule fails, using an assistant's draft. The recording is the one from lessons 0.3 to 0.5, the account discovery on WORKSTATION5.

No SIEM or security product is needed. The rule's logic runs here with jq against the recording, so you can see it match, and the Sigma and KQL versions are shown for reading. Module 9 runs rules in a real detection platform.

1

The Shape of a Response

NIST SP 800-61 Rev. 3: preparation, three Functions, and improvement throughout

NIST's incident response guidance, Special Publication 800-61, was revised in 2025. Its third revision frames incident response within the NIST Cybersecurity Framework 2.0, whose six Functions are Govern, Identify, Protect, Detect, Respond and Recover. Section 2 of the publication proposes a life cycle model built on those Functions.

PreparationGovern, Identify, ProtectDetectnotice and analyzeRespondcontain and eradicateRecoverrestore serviceImprovementlessons into every Function

NIST SP 800-61 Rev. 3's model: preparation outside the response, three Functions within it, improvement throughout

The model separates preparation from response. Govern, Identify and Protect are preparation: the policies, inventories and protections an organization puts in place before anything happens. The publication says plainly that these are not part of incident response itself. The response is Detect, Respond and Recover: noticing and analyzing the incident, containing and removing it, and restoring normal operations.

That separation has a practical meaning for an analyst. When an incident is underway, it's too late to start collecting a log, write a runbook or agree who may isolate a server. Those are preparation, and their absence shows up during response as delay. Many of the gaps an investigation finds, such as the missing endpoint logs in Module 1's environment, are preparation gaps, and the right home for them is the improvement list.

Running through all of it is improvement. The publication treats the lessons from every Function as a continuous activity, not a meeting held once at the end. A response that finds a gap in detection, a missing log or an unclear runbook feeds those findings back into preparation, and the next incident starts from a better position.

For an analyst, the model is useful mainly as shared vocabulary. Saying "we're in Respond" tells everyone that the incident has been confirmed and containment is underway. Saying "this is an Improvement item" tells them a finding should change preparation rather than wait in a report. Lesson 1.4 described incidents as declarations; the model describes what happens once one is declared.

The analyst's part sits mostly in Detect and in supporting Respond. Analysts notice and analyze, and they gather the evidence that response decisions rest on. The decisions themselves usually belong to incident leads and system owners, within the authority lesson 1.1 described.

2

The Earlier Life Cycle, Mapped

Four phases many teams still use, and where each one lands

Many organizations still describe incident response in the earlier revision's four phases: preparation; detection and analysis; containment, eradication and recovery; and post-incident activity. Runbooks, training and tools often use those words. Rev. 3 maps them onto the Functions in its Table 1:

Rev. 2's phasesthe familiar life cyclePreparationDetection and AnalysisContainment, Eradication, RecoveryPost-Incident ActivityRev. 3's CSF 2.0 Functionsas Table 1 maps themGovern, Identify, ProtectpreparationDetectwith ImprovementRespond, Recoverwith ImprovementIdentify: Improvementlessons learned

The earlier phases and the Functions Rev. 3 maps them to, row for row

Preparation becomes Govern, Identify and Protect. Detection and analysis becomes Detect. Containment, eradication and recovery splits into Respond and Recover. And post-incident activity becomes the Improvement category within Identify, which the model applies throughout rather than at the end.

The mapping matters when you read older documents alongside newer ones. A runbook written for the four phases still works. Its "post-incident activity" step is Rev. 3's Improvement, and Rev. 3's point is that improvement shouldn't wait until after the incident. If the response finds a missing log on day one, the request to start collecting it can go in on day one.

It matters for metrics too. Teams often measure how long each phase takes: time to detect, time to contain, time to recover. Those measurements carry across models as long as everyone agrees which Function each step belongs to. Agreeing that in advance, and writing the stage into each case note, is what makes the numbers comparable from one incident to the next.

The two models agree on the substance: prepare, notice, contain, remove, restore and learn. They differ in emphasis, and Rev. 3's emphasis fits how security teams now work, with detection and response running continuously rather than as one-off projects.

For this course, the words matter less than the sequence and the records each stage produces. Every stage leaves decisions and actions that someone will want to review, which is why the next section records them.

Whichever model your organization uses, learn its vocabulary and use it in your notes. A case note that says which stage an action belongs to makes the response easier to follow and to review, and it's what the next section does.

If the runbook and the guidance use different words, add a line to your notes mapping one to the other, so a reader from either background can follow.

3

A Response, Recorded

Who did what, at which stage, under whose authority
ONE LAUNCHER, WHAT IT DID, AND ITS ONE WAY OUTPowerShell -encstarted under pgustavoLauncher scriptdecoded from -encLogging offAMSI offAccounts listedAgent in memoryHTTP, RC4-encrypted10.10.10.5/admin/get.phpEach capability is a containment target; the channel out is the one to cut first

The decoded launcher's capabilities, from its own text and the records, and the server it fetched its agent from

The figure is what the responders were dealing with, read from the decoded launcher of lesson 0.4: two protections switched off, accounts listed, and an agent fetched from 10.10.10.5 and run in memory. Each is something to contain, and the channel out is the one to cut first. Here's a short response to the account discovery from lessons 0.3 to 0.5, recorded stage by stage in the incident's notes. The recording itself is real. This response is an example written for the lesson, showing what a well-kept record looks like:

Incidents›Account discovery on WORKSTATION5
OverviewAlertsEvidenceComments & Attachments
A
Analyst22 Sep 2020 00:05:00
StageDetectDoneTriage note written; T1087.001 mapped; parent PowerShell with encoded commandDecisionEscalated to the incident lead
IL
Incident lead22 Sep 2020 00:20:00
StageRespondDoneWORKSTATION5 isolated from the network; pgustavo sessions revokedAuthorityRunbook: lead may isolate a workstation
A
Analyst22 Sep 2020 02:10:00
StageRespondDonePowerShell process chain collected; program removed; account password reset
DT
Desktop team22 Sep 2020 09:30:00
StageRecoverDoneWORKSTATION5 rebuilt and returned to the user; monitoring for 7 days
IL
Incident lead25 Sep 2020 14:00:00
StageImprovementDoneDetection owner asked to alert on encoded PowerShell starting net.exe
Add a comment

A response recorded stage by stage: an example written for this lesson, around the recording in lessons 0.3 to 0.5

Each entry names the stage, what was done, by whom and when. The containment step names its authority, because isolating a machine is an action someone must be entitled to take. The final entry is an improvement item, and it's specific: a detection for encoded PowerShell starting net.exe, which is the pattern lesson 0.4 found in the records.

Notice the order. Detection and analysis came first, and the escalation happened only once the analyst had something specific to report. Containment came before removal, because removing the program while the machine was still connected could alert whoever controlled it. Recovery came after removal, and with monitoring, because a rebuilt machine that's immediately compromised again is a sign the cause wasn't found.

The record is also what makes improvement possible. Weeks later, someone reviewing the incident can see how long each stage took, which decisions were made by whom, and which follow-ups were raised. Without the record, the review relies on memory, and memory is kind to the people involved and unkind to the facts.

Records like this are also evidence in their own right. If the incident leads to a dispute, an insurance claim or a regulator's question, the response record shows what was known when each decision was made. Lesson 1.7's habits apply: timestamps in UTC, actions tied to people, and nothing rewritten after the fact.

Module 9 works through a developing incident in this shape, with the extra difficulty that real incidents rarely announce their stages. Containment often begins before analysis is finished, and recovery can be partial. The record keeps it clear regardless.

Notice too that every action in the record is tied to evidence that came before it. The isolation followed the escalation; the removal followed the collection of the process chain. A response record in which actions appear before the evidence that justified them is a sign that decisions were made on assumption, and a reviewer will ask about each one.

4

What a Detection Rule Is

A query is only one of six parts, and each changes what reaches an analyst
A DETECTION PIPELINE, WITH THE RULE OPENEDTelemetrySysmon event 1Rulelogic, scheduleAlertfor a personTriagereal or notResponsecontain, recoverOpened: this lesson's rule, as jq, and what it matched in the fileMatch a Sysmon process start (EventID 1) whose program is net.exe or net1.exeand whose command line holds the word user on its own, as in net userRun against the file, it matches 2 records, both on WORKSTATION5: "C:\windows\system32\net.exe" user andC:\windows\system32\net1 user

The rule is one stage of five: what it matches decides what every later stage sees

The figure places the rule in the pipeline it feeds and opens it. Detection is where the next incident starts, and in most security operations it starts with a rule. Microsoft Sentinel's documentation for scheduled rules describes their parts:

A scheduled detection rulethe parts Microsoft Sentinel asks forQuerythe logic: which records matchFrequency and lookbackhow often it runs, how far back it readsThresholdhow many results raise an alert, per runGroupingone alert for all results, or one eachEntity mappingwhich fields name the user, host, IPSuppressionquiet time after an alert, up to 24 hours

A rule is more than its query: six parts, each of which changes what reaches an analyst

The query is the logic: which records match. Frequency and lookback decide how often the query runs and how far back each run reads. The documentation notes that both must be between five minutes and fourteen days, and that the interval can't exceed the lookback. The threshold sets how many results a run needs before it raises an alert, applied to each run separately. Grouping decides whether all of a run's results become one alert or each becomes its own. Entity mapping tells the alert which fields name the user, host or address, so they appear on the alert and can be followed. And suppression stops a rule repeating its alert for up to a day.

Each part changes what an analyst sees. A good query with a lookback shorter than its source's delay, as lesson 1.9 showed, can miss late records entirely. A threshold set too high hides single events, and one set too low floods the queue. Grouping everything into one alert can hide a second victim inside the first alert. Entities that aren't mapped mean the analyst has to dig names out of raw results by hand.

Other products use different words for the same parts. Microsoft Defender's custom detections, Splunk's correlation searches and Elastic's rules all have logic, a schedule, a threshold, a way of grouping and a way of naming entities. Learn the parts once, and every product's settings page makes sense.

Module 9 asks you to improve one detection. Most improvements turn out to be in the parts around the query, not the query itself.

It's worth reading a rule's settings as carefully as its query when an alert seems wrong. An alert that fires an hour late often has a lookback and frequency problem, not a logic problem. An alert that names the wrong user often has an entity mapping problem. An alert that should have fired twice and fired once is often grouping or suppression. Each of those is fixed in the settings, without touching the query at all.

5

One Rule's Logic, Three Ways

Plain words, Sigma, KQL, and the logic run against the recording

A rule's logic should be expressible in plain words first: alert when net.exe or net1.exe starts with user as an argument. That sentence is the rule. Everything else is translation into a particular product's language.

Here it is in Sigma, an open format for writing detection logic independently of any product, and in KQL for Microsoft's process table. Both are written for this lesson:

title: Local account discovery with net.exe
status: experimental
logsource:
  product: windows
  category: process_creation
detection:
  image:
    Image|endswith:
      - '\net.exe'
      - '\net1.exe'
  args:
    CommandLine|re: '(?i)\suser(\s|$)'
  condition: image and args
falsepositives:
  - Administrators and scripts listing local accounts
level: low
# the same logic in KQL
DeviceProcessEvents
| where FileName in~ ("net.exe", "net1.exe")
| where ProcessCommandLine matches regex @"(?i)\suser(\s|$)"

The Sigma version names the log source, the conditions on the program and the command line, and how they combine. It also records the expected false positives and a severity, which is good practice: a rule that says who else will trigger it is a rule someone can tune. The KQL version expresses the same conditions against a different table with different field names: FileName and ProcessCommandLine instead of Image and CommandLine.

Neither can run on this page, which has no SIEM. The logic can, though. Here it is as a jq filter, run against the recording:

$ cat rule.jq
select(.EventID == 1
  and (.Image | test("\\\\net1?\\.exe$"; "i"))
  and (.CommandLine | test("\\suser(\\s|$)"; "i")))
| "\(.UtcTime)  \(.Hostname | split(".")[0])  \(.CommandLine)"
$ jq -r -f rule.jq net-local-users.json
2020-09-21 23:26:20.869  WORKSTATION5  "C:\windows\system32\net.exe" user
2020-09-21 23:26:20.885  WORKSTATION5  C:\windows\system32\net1 user

Both process starts match: net.exe with user, and net1.exe with user. The rule finds the behavior it was written for, on a real recording of it. That's the minimum test for any detection: run it against a known example and confirm it fires. A rule that hasn't passed that test is a hope, not a detection.

The second test is harder: who else does it fire on? Section 2 of lesson 0.4 answered that already. Administrators listing accounts would trigger it too, which is why the Sigma rule says so and sets its level low. A better rule might add the context lesson 0.4 found, the encoded PowerShell parent, which is exactly the improvement item in section 3's notes.

Measuring that is easy once the logic exists: run it over a normal period and count. The count, divided by the number of genuine cases you'd expect, tells you how much of an analyst's time the rule will cost. Rules are budgets as much as logic.

Writing the rule in plain words first also makes it reviewable by people who don't read Sigma or KQL. An incident lead can agree or disagree with "alert when net.exe or net1.exe starts with user as an argument" in seconds. That review is worth having before anyone spends time on syntax, because most rule problems are problems with the idea rather than the language.

6

Testing a Rule Before Trusting It

Known positives, expected false positives, and the test nobody runs

Every rule should be tested in two directions before it goes live. Does it fire on the behavior it's meant to catch? And how often does it fire on everything else?

The first test needs a known example: a recording like this one, a test run in a lab, or a past incident's records. The second needs a period of normal activity: run the logic over a week of ordinary records and count the matches. If administrators run net user forty times a week, a rule that alerts on every one will be muted within a month, and then it catches nothing.

Public recordings like OTRF's are built for exactly this. They capture real tools performing real techniques in a lab, so defenders can test detections against them without running the tools themselves. Module 9 uses them alongside the course's own case data.

Here are the three checks on the recording: the source exists, the machines it covers, and where the rule fires:

$ jq -r 'select(.Channel == "Microsoft-Windows-Sysmon/Operational")
    | .EventID' net-local-users.json | sort -n | uniq -c
      5 1
      8 3
      3 22
$ jq -r 'select(.EventID == 1) | .Hostname' net-local-users.json | sort | uniq -c
      2 WORKSTATION5.theshire.local
      3 WORKSTATION6.theshire.local
$ jq -r -f rule.jq net-local-users.json | awk '{print $3}' | sort | uniq -c
      2 WORKSTATION5

Sysmon's process events are present, from both workstations, and the rule fires only on WORKSTATION5, where the behavior happened. The three process starts on WORKSTATION6, all routine system processes, don't match. On a recording this small that's reassuring and not conclusive. A week of real activity is the real test.

There's a third test that's easy to skip: does the rule's data source actually exist where the rule runs? A rule on Sysmon process events is useless in a workspace that doesn't collect Sysmon. Lesson 1.9's data check applies to rules as much as to investigations. Check that the table has data, that the fields have the names the rule uses, and that the values are in the form the rule expects.

The assistant's draft in the next section fails the first test, and it fails it silently. That's the dangerous kind of failure. A rule that errors gets fixed. A rule that runs cleanly and matches nothing stays in production, looking like coverage.

The fix is cheap: always run a new rule against at least one known positive, and record the result with the rule. "Fires on the OTRF net user recording, two matches" is a line of documentation that proves the rule can work.

Keep the known positive alongside the rule, too. When the rule is edited months later, rerunning it against the same example shows immediately whether the edit broke it.

7

When an Assistant Writes the Rule

A sensible condition that matches nothing in real records

Assistants write detection logic quickly, and their drafts are usually plausible. Here's one asked for this rule:

AI assistantNew chat

Write a detection for account discovery with net user, on Sysmon process creation events.

Match process creation where CommandLine contains "net user". That catches anyone running net user to list or query accounts. Set the severity to medium.

Reply to AI assistant...

Check before you use it

Run against the recording, it matches nothing. Windows records the full path, so the command line reads "C:\windows\system32\net.exe" user, and the helper process reads net1 user. Neither contains the text "net user". A rule that matches nothing on a known example would never alert, and nobody would notice.

An illustrative exchange, written for this lesson: an assistant you ask will word it differently.

The condition reads naturally: the command line contains "net user". Run against the recording, it matches nothing:

$ jq -r 'select(.EventID == 1 and (.CommandLine | test("net user"; "i")))
    | .Image' net-local-users.json | wc -l
0
$ jq -r 'select(.EventID == 1 and (.Image | test("net"; "i")))
    | .CommandLine' net-local-users.json
"C:\windows\system32\net.exe" user
C:\windows\system32\net1 user

The command lines show why. Windows recorded the full path of the program, so net.exe's command line reads with the path in quotes before the argument, and the helper process records itself as net1 user. Neither contains the exact text "net user". A person typing at a console would write "net user", which is presumably what the assistant pictured. The records don't look like that.

That's the general lesson about assistant-written detections, and about detections written from memory: the logic has to match the records as they're actually written, and only a test against real records shows whether it does. An assistant can't run that test unless you give it the records. Give it a real example, and ask it to confirm its logic matches. Most will correct themselves when they see the data.

Then run the test yourself anyway, and keep the result with the rule. A rule's history of tests is part of the rule, as much as its logic and its settings.

Assistants are genuinely helpful in detection work once the test is in place. They translate logic between formats quickly, suggest conditions you hadn't thought of, and explain unfamiliar operators. The workflow that works is simple: describe the behavior in plain words, give the assistant a real matching record, ask for the rule, and run the rule against that record and a sample of normal activity. The assistant writes; the records decide.

The same caution applies to rules from any outside source: a vendor's content pack, a shared repository, a colleague's notes. Every one was written against someone else's records. Field names, value formats and the shape of command lines vary between environments and products, and a rule that works perfectly elsewhere can match nothing in yours until it's tested there.

Practice

Do

Practice

Write a rule's logic and test it on a known case
the recording

Use the recording from lessons 0.3 to 0.5. The command lines and fields you need are shown in this lesson and in lesson 0.4.

You don't need a SIEM or any other security product. Writing the logic in plain words and tracing it by hand against the two command lines is enough to find the problems this lesson shows.

Do this Write a rule's logic and test it on a known case
  1. State the behavior. In one sentence, describe what the rule should find, using the recording in lessons 0.3 to 0.5.
  2. Write the logic. Name the fields and the conditions, in plain words first and then in any format you know.
  3. Test it. Run it, or trace it by hand, against both process starts and say whether each matches.
  4. Name the cost. Write who else would trigger it, and what the rule's threshold, grouping and entities should be.
You will have a detection idea tested against a real example and its false positives named, the loop Module 9 runs in full.

Lesson 0.10, the last foundation lesson, turns everything this module has covered into writing: a finding and a short report that a reader outside security can act on.