Detect Spearphishing Link in Google Chronicle
Adversaries may send spearphishing emails with a malicious link in an attempt to gain access to victim systems. Unlike spearphishing attachments, this variant embeds URLs in email body text, requiring the recipient to actively click or paste the link into a browser. Clicked links may deliver browser exploits, prompt downloads of malware or scripts, or harvest credentials via convincing login pages. Advanced variants include OAuth consent phishing (abusing OAuth 2.0 authorization flows to steal application access tokens), device code phishing (abusing OAuth 2.0 device authorization grant to obtain persistent tokens), and IDN homograph attacks where lookalike Unicode domains impersonate trusted brands. URLs may also be obfuscated via URL shorteners, integer-format IP addresses (e.g., hxxp://1157586937), or the @ symbol trick. Threat actors including Kimsuky, MuddyWater, BlackTech, LuminousMoth, DarkGate, and Squirrelwaffle have extensively leveraged this technique.
MITRE ATT&CK
- Tactic
- Initial Access
- Technique
- T1566 Phishing
- Sub-technique
- T1566.002 Spearphishing Link
- Canonical reference
- https://attack.mitre.org/techniques/T1566/002/
YARA-L Detection Query
rule t1566_002_spearphishing_link_spawn {
meta:
author = "df00tech Detection Engineering"
description = "Detects T1566.002 Spearphishing Link follow-on execution: email clients, browsers, or mshta.exe spawning suspicious scripting or execution utilities"
severity = "HIGH"
priority = "HIGH"
mitre_attack_tactic = "Initial Access"
mitre_attack_technique = "T1566.002"
reference = "https://attack.mitre.org/techniques/T1566/002/"
created = "2026-04-21"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.principal.process.file.full_path != ""
// Parent is email client, browser, or mshta
(
re.regex($e.principal.process.file.full_path, `(?i)(outlook\.exe|thunderbird\.exe|teams\.exe|msoutlook\.exe|msedge\.exe|chrome\.exe|firefox\.exe|iexplore\.exe|opera\.exe|brave\.exe|mshta\.exe)$`)
)
// Child is a suspicious process
(
re.regex($e.target.process.file.full_path, `(?i)(powershell\.exe|pwsh\.exe|cmd\.exe|wscript\.exe|cscript\.exe|mshta\.exe|rundll32\.exe|regsvr32\.exe|msiexec\.exe|certutil\.exe|bitsadmin\.exe|curl\.exe|wget\.exe)$`)
)
// Exclude legitimate browser sub-processes
not re.regex($e.target.process.command_line, `(?i)(--type=renderer|--type=utility|--type=gpu-process|--type=crashpad-handler|--extension-process|NativeMessagingHost|MicrosoftEdgeUpdate|GoogleUpdate|ChromeSetup|EdgeUpdate)`)
// Exclude msiexec update launches from browsers (already captured above but belt-and-suspenders)
not (
re.regex($e.target.process.file.full_path, `(?i)msiexec\.exe$`) and
re.regex($e.target.process.command_line, `(?i)(MicrosoftEdgeUpdate|GoogleUpdate|ChromeSetup|EdgeUpdate)`)
)
$host = $e.principal.hostname
$parent = $e.principal.process.file.full_path
$child = $e.target.process.file.full_path
$cmdline = $e.target.process.command_line
$user = $e.principal.user.userid
condition:
$e
} Chronicle YARA-L 2.0 rule detecting spearphishing link follow-on execution by monitoring PROCESS_LAUNCH events where email clients (Outlook, Thunderbird, Teams), web browsers (Edge, Chrome, Firefox, Opera, Brave), or mshta.exe spawn known-suspicious execution utilities. Excludes legitimate browser internal sub-processes using command-line pattern matching.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate software installers invoked through browser clicks (e.g., clicking a download link that opens an msiexec installer) where the update process exclusions do not match the specific installer string
- Corporate IT tools deployed via Teams or Outlook plugins that legitimately invoke PowerShell or cmd.exe as part of approved automation workflows
- Security tools or EDR agents that hook into browser processes and launch sub-components that match the suspicious child process list
Other platforms for T1566.002
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Email Client Spawning PowerShell via Link Handler
Expected signal: Sysmon Event ID 1: Process Create — Image=powershell.exe, CommandLine contains '-WindowStyle Hidden' and 'Net.WebClient' and 'DownloadString'. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 (connection refused). Security Event ID 4688 if command line auditing is enabled. PowerShell ScriptBlock Log Event ID 4104 with full script content.
- Test 2Browser Spawning MSHTA via HTA File Download
Expected signal: Sysmon Event ID 1: Process Create — Image=mshta.exe, ParentImage=msedge.exe (or cmd.exe depending on Edge's open handler). Sysmon Event ID 11: File creation event for df00tech-test.hta in %TEMP%. Security Event ID 4688 for mshta.exe process creation with full command line including path to HTA file.
- Test 3OAuth Device Code Phishing Flow Initiation
Expected signal: Sysmon Event ID 1: Process Create — Image=powershell.exe, CommandLine contains 'devicecode' and 'login.microsoftonline.com'. Sysmon Event ID 3: Network connection to login.microsoftonline.com on port 443. Sysmon Event ID 22: DNS query for login.microsoftonline.com. Azure AD sign-in logs: device code flow request entry visible in non-interactive sign-in logs for the test client_id (04b07795 is the Azure CLI client ID, a well-known public client).
- Test 4Malicious Link Payload Drop Simulation
Expected signal: Sysmon Event ID 11: File creation in %TEMP% for Invoice_2026-03-12.pdf.cmd (double extension with .cmd as final extension). Sysmon Event ID 1: Process Create — Image=cmd.exe, CommandLine references the %TEMP% staged file path, ParentImage=powershell.exe. Security Event ID 4688 for both powershell.exe and cmd.exe. The temporal pattern of PowerShell network activity followed by file creation in staging dir followed by cmd.exe execution matches the hunting query for email client network + file drop correlation.
References (11)
- https://attack.mitre.org/techniques/T1566/002/
- https://us-cert.cisa.gov/ncas/tips/ST05-016
- https://www.mandiant.com/resources/blog/url-obfuscation-schema-abuse
- https://www.microsoft.com/security/blog/2021/07/14/microsoft-delivers-comprehensive-solution-to-battle-rise-in-consent-phishing-emails/
- https://www.secureworks.com/blog/oauths-device-code-flow-abused-in-phishing-attacks
- https://www.netskope.com/blog/new-phishing-attacks-exploiting-oauth-authorization-flows-part-1
- https://www.optiv.com/insights/source-zero/blog/microsoft-365-oauth-device-code-flow-and-phishing
- https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/safe-links-about
- https://learn.microsoft.com/en-us/defender-xdr/advanced-hunting-urlclickevents-table
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1566.002/T1566.002.md
- https://blog.trendmicro.com/trendlabs-security-intelligence/pawn-storm-abuses-open-authentication-advanced-social-engineering-attacks
Unlock Pro Content
Get the full detection package for T1566.002 including response playbook, investigation guide, and atomic red team tests.