Reading width
Wide uses the full column for everything, text, diagrams, code, and exercises. Narrow keeps the standard reading width.
Text size
Scales the body text. Headings and code blocks keep their size.
In this section
0.5 Correlation and Multi-Stage Attacks
Introduction
Most rules in this course look at one kind of event. Attacks are sequences. A single intrusion leaves records in email, endpoint, network, identity and mailbox logs, each of which an individual rule might catch or miss, and each of which on its own can look like something ordinary.
Correlation is the set of techniques for reading records together: across sources, in order, and against what each account or machine normally does.
This lesson reads two intrusions whole. The first is one person's afternoon on 27 February, which earlier lessons met in pieces: the invoice and the macro in lesson 0.2, the beacon in lesson 0.8, the replayed session in lesson 0.6.
The second is the night of 15 March, when the file server was encrypted. Between them they show why correlation finds what single rules miss, and why it is harder to get right.
Many Records, One Intrusion
reading an afternoon across five sourcesEvery record in the figure above is in a different table. One query can read them together, renaming each source's time and description to the same columns, the union pattern lesson 0.3 used for one command in three sources:
union
(EmailEvents
| where RecipientEmailAddress == "b.collins@ne.com"
and SenderFromAddress == "invoices@kestrel-logistlcs.com"
| project TimeGenerated = Timestamp, Source = "Email", What = Subject),
(DeviceProcessEvents
| where DeviceName startswith "ne-collins-lt"
and InitiatingProcessFileName =~ "winword.exe"
| project TimeGenerated = Timestamp, Source = "Endpoint",
What = strcat(FileName, " started by Word")),
(DeviceNetworkEvents
| where DeviceName startswith "ne-collins-lt" and RemoteIP == "198.51.100.62"
| summarize TimeGenerated = min(Timestamp)
| extend Source = "Network", What = "first check-in to 198.51.100.62"),
(union SigninLogs, AADNonInteractiveUserSignInLogs
| where UserPrincipalName == "b.collins@ne.com" and IPAddress == "192.0.2.157"
| summarize TimeGenerated = min(TimeGenerated)
| extend Source = "Identity", What = "session used from 192.0.2.157"),
(OfficeActivity
| where UserId == "b.collins@ne.com" and Operation == "Set-Mailbox"
| project TimeGenerated, Source = "Mailbox",
What = "forwarding set to an outside address")
| where TimeGenerated between (datetime(2026-02-27) .. datetime(2026-02-28))
| order by TimeGenerated asc
In order: an invoice arrives from a domain one letter away from a real supplier's; fourteen minutes later Word starts PowerShell; two minutes after that the laptop starts checking in with an outside server every five minutes; about forty minutes later the user's session is used from a hosting address; and twenty-three minutes after that, from the same address, the mailbox is set to forward everything to an outside account.
A phish, code execution, command and control, session theft and data theft, in a little over an hour.
Each record belongs to a rule somewhere in the course. The email to Module 14, the macro to Module 10, the beacon to Module 13, the session to Module 12, the forwarding to Module 14 again. Each of those rules can be good and still produce five separate alerts, possibly for five analysts, possibly hours apart, each judged on its own as probably benign.
The value of correlation is the sentence above: the same account, in order, in an hour. That sentence is what an analyst needs, and it is what a correlation rule produces.
The union query is also how an analyst works the incident after any one alert fires. Starting from the forwarding alert, the question is what else happened to this account and this laptop that day, and the answer is this query with the account and the machine as its keys.
Notice what made the query possible: every source named the same person or the same laptop in a way the query could match, and every source had a timestamp the query could sort. Neither is guaranteed. The mailbox log names the user by UPN, the endpoint by device and account, the firewall by internal address.
The beacon joins the rest here only because Defender recorded it on the laptop by name; the firewall's copy of the same connections would need the laptop's address for that day. A correlation is only as complete as the identifiers that link its sources.
Joining Two Sources
code on the laptop, then a risky sign-inA correlation rule joins records from different sources on a shared key, within a time window, and alerts on the combination. The rule for the second and fourth steps of the afternoon: PowerShell started by an Office application, followed within two hours by a medium or high risk sign-in for the same person:
let Risky = union SigninLogs, AADNonInteractiveUserSignInLogs
| where RiskLevelDuringSignIn in ("medium", "high")
| project SignInTime = TimeGenerated, UserPrincipalName, IPAddress,
RiskLevelDuringSignIn;
DeviceProcessEvents
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe",
"powerpnt.exe", "outlook.exe")
| project CodeTime = Timestamp, DeviceName, AccountUpn,
Parent = InitiatingProcessFileName
| join kind=inner Risky on $left.AccountUpn == $right.UserPrincipalName
| where SignInTime between (CodeTime .. CodeTime + 2h)
| summarize CodeTime = min(CodeTime), SignInTime = min(SignInTime)
by AccountUpn, DeviceName, Parent, IPAddress, RiskLevelDuringSignIn
It returns one row: b.collins, Word as the parent, the risky sign-in 41 minutes after the code. The month has a look-alike with both halves. An engineer at a hotel ran a drive-mapping script in PowerShell from Explorer and then signed in from the hotel's network, which Entra ID rated medium risk. Scored with and without the parent condition:
Without the parent, the rule flags the hotel. The halves are both present; what differs is that one PowerShell came from a document and the other from a person double-clicking their own script. A correlation inherits the precision of its parts, and a loose part makes a loose correlation, however many parts it joins.
The join key is the account, named AccountUpn in Defender's process records and UserPrincipalName in the sign-in logs. Lesson 0.3 showed what happens when one source names a person differently: the join returns nothing, silently.
For this account the two names agree. For j.okonkwo, whose Windows account name differs from the UPN, a join on account name rather than UPN would never fire, which is why Module 8 resolves people through the directory before joining.
The join here is inner: only accounts with both halves survive. That is the right choice for an alert, because either half alone is common. It is the wrong choice for an investigation, where the question is what each half's account did, and a left outer join keeps the code even when no risky sign-in followed.
Module 6 covers the join kinds, and Module 8 uses each where it fits. The choice is part of the rule's specification, written down before the query, because the two kinds answer different questions about the same data.
Order and Timing
what a join window has to allow forA correlation is a claim about time as well as identity, and every part of that claim has to be set deliberately:
What a correlation has to decide about time
join window and orderThe window bounds how far apart the steps can be. Too short and a patient attacker walks past it; too long and unrelated events on a busy account join by coincidence. Two hours suited this attack because the session theft followed the code within the hour. Module 8 sets windows from the gaps in real intrusions and the rate of coincidental pairs in the estate, not by guess.
Order matters because reversing it changes the meaning. A risky sign-in followed by PowerShell from Word might be a person signing in from a hotel and then opening a document, an ordinary sequence. Code followed by a session used from somewhere new is the theft pattern. The rule's between clause encodes the order.
Arrival is the subtle part, and lesson 0.6 showed it defeating a rule. The two halves come from different pipelines: Defender's process records usually arrive within minutes, sign-in records on their own schedule.
A rule that runs before the later half has arrived cannot see the pair, and if its lookback does not reach back far enough on the next run, it never will. Correlation rules need a lookback of at least the window plus the slower source's delay, and Module 8 measures both from the data before setting either.
Scheduling a correlation is therefore a trade. A short lookback keeps each run cheap and alerts quickly, but loses pairs whose halves arrive late or far apart. A long lookback catches them, reads more data on every run, and can raise the same pair on several runs unless the rule suppresses repeats, the duplication lesson 0.6 found when a lookback was widened.
The course replays every correlation on its real schedule for this reason: the query's logic and the schedule's reach are tested together, because either can lose the attack.
Against the Entity's Own History
three bursts of activity on one file serverSome attacks are not a sequence of different events but one kind of event in unusual volume. Encryption is the clearest: a ransomware process rewrites every file it can reach. The three busiest hours of file activity on the file server in the month:
DeviceFileEvents
| where DeviceName startswith "srv-nge-mcr-fs01"
| where ActionType in ("FileCreated", "FileRenamed", "FileModified", "FileDeleted")
| summarize Events = count() by Day = format_datetime(Timestamp, "yyyy-MM-dd"),
Hour = datetime_part("hour", Timestamp)
| top 3 by Events
One of those hours is the attack. The other two are a designer re-saving a batch of drawings, which writes a backup of each, and an administrator moving a closed project's folders to the archive, which creates a copy and deletes the original of every file.
The migration is the busiest of the three, so a rule on volume alone either catches the migration as well as the attack or misses the attack. Looking inside each burst:
DeviceFileEvents
| where DeviceName startswith "srv-nge-mcr-fs01"
| where Timestamp between (datetime(2026-03-05 16:00) .. datetime(2026-03-05 16:30))
or Timestamp between (datetime(2026-03-07 10:00) .. datetime(2026-03-07 10:20))
or Timestamp between (datetime(2026-03-15 02:25) .. datetime(2026-03-15 02:55))
| extend Ext = tostring(split(FileName, ".")[-1])
| summarize Events = count(), Sources = dcount(RequestSourceIP),
Accounts = dcount(RequestAccountName),
NewNames = make_set_if(Ext, ActionType == "FileRenamed", 3),
Actions = make_set(ActionType)
by Day = format_datetime(Timestamp, "MM-dd")
The attack is the only burst from one address that renames files to an extension the server had never seen, 1,116 renames to .kx7q, and it also writes a ransom note, 25 copies of RESTORE-FILES.txt in the folders it touched.
The re-save came from several people's machines and renamed files to .bak, an extension the server sees every week. The migration came from one administrator and renamed nothing; it created and deleted.
That is what judging against the entity's own history means. The question is not whether this is a lot of activity, but whether this server has seen this kind of activity, from this kind of source, before. A new file extension appearing in volume, from a single address, is rare on any file server; a burst of .bak files is not.
Module 14 builds the mass-modification rule on that distinction, and Module 8 builds the per-entity baselines it depends on. The same reasoning also handles the look-alikes over time: if the design team starts re-saving drawings every Thursday, the baseline learns it, and the rule stays quiet without anyone adding an exclusion.
Weak Signals That Add Up
scoring an account rather than an eventThe afternoon of 27 February produced several signals that would each be a poor alert on its own:
Signals on b.collins, 27 February, each weak on its own
one account, one afternoonMedium-risk sign-ins happen constantly, for travel, new devices and mobile networks. Office starting PowerShell happens in teams that use macros. A new outside destination is every new website. Alerting on each would drown a queue; ignoring each misses this intrusion.
Risk-based alerting takes a third path: each signal adds to a score for the account or machine it concerns, without raising an alert, and an alert fires when an entity's score over a window crosses a threshold.
The idea is that attacks concentrate signals on a few entities and ordinary activity spreads them thinly. One medium-risk sign-in adds a little to one person's score; five different kinds of signal on one account in two hours add a lot.
The design questions are the same as for any rule: which signals count and how much, over what window, and which look-alikes, such as an administrator whose normal work trips several signals daily, have to be tested against. Module 8 builds a risk-based rule on this account and the hotel look-alike, whose score rises and should not cross.
Scoring also changes what an alert says. Instead of one event and a rule name, the analyst gets an account and the list of signals that put it over the line, which is close to the timeline in section one. The alert is the beginning of the investigation rather than a pointer to it.
The weights are where risk-based alerting goes wrong. A signal that fires often for ordinary reasons, weighted too heavily, pushes routine accounts over the line; a signal weighted too lightly never contributes. Setting weights from the labeled month, where both the intrusion and the look-alikes are known, is what keeps the scores honest, and they have to be revisited as the estate changes.
Rules That Hide an Attack
mailbox forwarding and the owner's viewEmail attacks often end in the mailbox's own settings, because a forwarding rule keeps sending mail long after the attacker's session has expired. Every rule or mailbox setting in the month that forwards mail:
OfficeActivity
| where Operation in ("New-InboxRule", "Set-Mailbox")
| mv-expand P = parse_json(Parameters)
| summarize Settings = make_bag(bag_pack(tostring(P.Name), tostring(P.Value)))
by TimeGenerated, UserId, Operation, ClientIP
| extend ForwardTo = coalesce(tostring(Settings.ForwardTo),
tostring(Settings.ForwardingSmtpAddress), tostring(Settings.ForwardingAddress))
| where isnotempty(ForwardTo)
| project TimeGenerated, UserId, Operation, ClientIP, ForwardTo,
RuleName = tostring(Settings.Name), Deletes = tostring(Settings.DeleteMessage)
Four forwards, two of them attacks. k.foster's rule, created from the replayed session of 25 February, forwards any message mentioning an invoice, payment, remittance or bank details to an outside address, deletes the original and stops other rules running, and its name is two dots, chosen to be easy to overlook in a list. b.collins's mailbox, from the afternoon in section one, forwards everything outside.
The other two are a shared mailbox forwarded to the colleague who now answers it, and a rule forwarding one supplier's invoices to a deputy during annual leave, both inside the organization and set from the office.
What separates them is what each does to the owner's view and where the mail goes. The leave rule forwards inside the company and leaves the original in place. The attacker's rule sends payment mail outside and deletes it, so the person who would notice a changed bank detail never sees the message.
That combination is the theft, and it is the practice at the end of this lesson. Module 14 builds the full rule, including the third attack, a rule added through Outlook that hides security warnings, which the audit log records in a different operation with a different shape.
Mailbox rules are also a good example of correlation in the other direction, from an alert back to its cause. A forwarding rule created from an address that also used the person's session that morning ties the rule to the session theft, and the session theft to whatever stole the cookie.
Starting from either end, an analyst who follows the address arrives at the whole afternoon. Module 14's rules carry that address as an entity so the link is made automatically.
The Last Night
from a laptop to an encrypted file serverThe intrusion that ends the month began on 10 March with a link in a remittance advice, which led to a zip, a shortcut and a program on a marketing laptop that then checked in every few hours. On the night of 15 March it moved:
union
(DeviceNetworkEvents
| where DeviceName startswith "ne-wright-lt" and RemotePort == 3389
| project TimeGenerated = Timestamp, Host = "ne-wright-lt",
What = strcat("RDP to ", RemoteIP)),
(DeviceProcessEvents
| where Timestamp between (datetime(2026-03-15 02:00)
.. datetime(2026-03-15 03:00))
| where FileName in~ ("vssadmin.exe", "wmic.exe", "bcdedit.exe", "wbadmin.exe")
or ProcessCommandLine has "Win32_ShadowCopy"
| project TimeGenerated = Timestamp, Host = tostring(split(DeviceName, ".")[0]),
What = ProcessCommandLine),
(DeviceFileEvents
| where DeviceName startswith "srv-nge-mcr-fs01" and FileName endswith ".kx7q"
| summarize TimeGenerated = min(Timestamp), Renames = count(),
LastRename = max(Timestamp)
| extend Host = "srv-nge-mcr-fs01",
What = strcat(Renames, " files renamed to .kx7q until ",
format_datetime(LastRename, "HH:mm")))
| project TimeGenerated, Host, What
| order by TimeGenerated asc
The laptop opened remote desktop sessions to two servers. Four minutes after the first, recovery was removed on the file server, the commands lesson 0.3 followed through three sources; six minutes later, on the backup server, shadow copies were removed through WMI and the backup catalog deleted. At 02:31 the encryption began on the file server, over the network from the same laptop, and ran for eighteen minutes.
Read as a sequence, each stage offered a defender something different:
The night of 15 March, stage by stage
what each stage gave a defenderThe value of detecting earlier stages is time. The implant gave nearly five days. The remote desktop session gave minutes. The recovery commands gave a quarter of an hour before encryption, enough for an automated response like the one in lesson 0.6 to isolate the server.
The encryption itself gives nothing but a list of what to restore. Module 14 builds a rule for each stage of this night, and Module 8's correlations connect them, so that the earliest detection can carry the context of what it is likely to lead to.
The night also shows the cost of detecting each stage in isolation. Several of its records would have raised alerts from rules elsewhere in this course, on different hosts, minutes apart.
Without correlation, an analyst sees an RDP connection from a laptop, then a vssadmin command on a server, then a backup catalog deleted on another, and has to connect them under pressure. With it, the second alert arrives already linked to the first, and the decision to isolate is made on the whole sequence.
What Modules 8 and 14 Build On It
correlation, then multi-stage attacksModule 8 builds correlation and behavioral analytics: endpoint activity then a risky sign-in, the rule in section two; order and arrival delay, with a key created and then a trail stopped; thresholds against each entity's own history; peer groups, a privilege nobody else on the team holds; and risk-based alerting, weak signals on one account.
Module 14 builds the multi-stage attacks: a phishing message, the click and the attachment that ran; a forwarding rule hidden behind a two-dot name; shadow copies deleted and recovery disabled; and mass file modification before encryption.
Both modules return to the two intrusions in this lesson, which is deliberate. A correlation rule is only as good as its understanding of a real attack's shape: which steps happen, in what order, how far apart, recorded where.
The labeled month holds those shapes, with look-alikes beside each, so that every correlation the course builds is tested against an attack that happened and an ordinary day that looked like one.
That completes the foundation for every module in the course, in the order a detection engineer meets the work.
The first five lessons covered what a detection is, what it observes, the data it reads, the languages it is written in and the sequences it joins; the last five covered running rules, the endpoint, identity and the network, testing and tuning, and keeping rules as code. Module 1 starts from there.
Practice
The exercise below is section six's mailbox rule. Make it find the rule that forwards and deletes, and leave the leave cover alone.
- Run the starting query. Note the two rules it returns and read their settings.
- Expand the settings. Turn the Parameters list into one bag of settings per rule.
- Find the difference. One rule forwards; the other forwards and deletes.
- Set the condition. Forwarding and deletion together.
- Check the score. The attacker's rule caught, the leave cover left alone.
An intrusion is a sequence of records across sources, each of which can look ordinary alone. Correlation reads them together: joined on a key both sources name the same way, within a window that allows for arrival delays, in the right order, or scored as weak signals on one entity.
Volume is judged against the entity's own history, and settings like mailbox rules are judged by what they do to the owner's view. Every one of those judgments is tested against a look-alike from the same month before it is trusted.
The next lesson follows rules, single-event and correlated alike, into production, where schedules, silent sources and unreviewed changes decide what they actually catch.