Correlating EmailEvents with DeviceProcessEvents in Microsoft Defender XDR.
The phishing email looked convincing.
The attachment appeared harmless.
Several users received the message.
One employee opened the attachment.
The email investigation confirmed delivery, but Agent Foskett knew emails do not execute malware.
Processes do.
To determine whether the attachment launched suspicious activity, he correlated EmailEvents with DeviceProcessEvents.
Lesson overview
Learn how to correlate EmailEvents with DeviceProcessEvents to determine what executed on a device after a phishing email was delivered or an attachment was opened.
Why this correlation matters
The fields used in this lesson
Step 1 — Review recent email deliveries
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
EmailEvents
| where Timestamp > ago(24h)
| project Timestamp,
RecipientEmailAddress,
SenderFromAddress,
Subject,
NetworkMessageId,
DeliveryAction
| order by Timestamp desc
Step 2 — Review recent process execution
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
DeviceProcessEvents
| where Timestamp > ago(24h)
| project Timestamp,
DeviceName,
AccountUpn,
FileName,
InitiatingProcessFileName,
ProcessCommandLine
| order by Timestamp desc
Step 3 — Correlate by user and timeline
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
EmailEvents
| where Timestamp > ago(24h)
| project EmailTime = Timestamp,
RecipientEmailAddress,
Subject,
NetworkMessageId
| join kind=inner (
DeviceProcessEvents
| where Timestamp > ago(24h)
| project ProcessTime = Timestamp,
AccountUpn,
DeviceName,
FileName,
InitiatingProcessFileName,
ProcessCommandLine
) on $left.RecipientEmailAddress == $right.AccountUpn
| where ProcessTime between (EmailTime .. EmailTime + 30m)
| project EmailTime,
ProcessTime,
RecipientEmailAddress,
DeviceName,
Subject,
FileName,
InitiatingProcessFileName,
ProcessCommandLine
| order by EmailTime asc
Step 4 — Hunt for suspicious Office child processes
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
DeviceProcessEvents
| where InitiatingProcessFileName in~ (
"WINWORD.EXE",
"EXCEL.EXE",
"POWERPNT.EXE",
"OUTLOOK.EXE"
)
| where FileName in~ (
"powershell.exe",
"cmd.exe",
"wscript.exe",
"cscript.exe",
"mshta.exe",
"rundll32.exe"
)
| project Timestamp,
DeviceName,
AccountUpn,
InitiatingProcessFileName,
FileName,
ProcessCommandLine
| order by Timestamp desc
Step 5 — Focus on risky command lines
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
DeviceProcessEvents
| where Timestamp > ago(7d)
| where ProcessCommandLine has_any (
"powershell",
"-enc",
"downloadstring",
"invoke-webrequest",
"iwr",
"mshta",
"rundll32"
)
| project Timestamp,
DeviceName,
AccountUpn,
FileName,
InitiatingProcessFileName,
ProcessCommandLine
| order by Timestamp desc
Step 6 — Build an email-to-process investigation timeline
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
EmailEvents
| where Timestamp > ago(24h)
| project EventTime = Timestamp,
EventType = "EmailDelivered",
Account = RecipientEmailAddress,
Detail = Subject
| union (
DeviceProcessEvents
| where Timestamp > ago(24h)
| project EventTime = Timestamp,
EventType = "ProcessExecuted",
Account = AccountUpn,
Detail = strcat(FileName, " | ", ProcessCommandLine)
)
| order by EventTime asc
How to read the results
Common investigation uses
Common mistakes
What you learned
Related Agent Foskett Academy lessons
Coming next
Final thought
Correlating EmailEvents with DeviceProcessEvents in Microsoft Defender XDR
Agent Foskett Academy Lesson 78 teaches defenders how to correlate EmailEvents with DeviceProcessEvents during Microsoft Defender XDR investigations.
Learn email to endpoint process investigation in Defender XDR
This lesson explains how EmailEvents, DeviceProcessEvents, RecipientEmailAddress, AccountUpn, FileName, InitiatingProcessFileName and ProcessCommandLine help defenders investigate whether suspicious endpoint execution followed phishing email delivery.
