T1137.005

Outlook Rules

Adversaries abuse Microsoft Outlook rules to achieve persistence and execute code. Malicious inbox rules can be configured to run a script or application when a specially crafted email is received. Rules are stored in the mailbox and persist across Outlook restarts and even OS reinstalls. The Ruler tool automates creation of malicious rules. Hidden inbox rules (stored without display names) are particularly stealthy.

Microsoft Sentinel / Defender
kusto
// T1137.005 — Outlook Rules persistence detection
// Rules stored in mailbox; execution triggers from email receipt
// Part 1: Detect processes spawned by Outlook that indicate rule execution
let OutlookRuleExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "outlook.exe"
| where FileName in~ ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe",
                      "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe")
| extend DetectionType = "Outlook_Rule_Execution"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Part 2: Detect Outlook spawning executables from user-writable locations (rule: run application)
let OutlookUserExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "outlook.exe"
| where FolderPath has_any ("\\Users\\", "\\Temp\\", "\\AppData\\", "\\ProgramData\\")
| where FolderPath !has "\\Microsoft Office\\"
| extend DetectionType = "Outlook_UserDir_Execution"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, FolderPath, DetectionType;
// Part 3: Detect Ruler tool targeting Outlook rules
let RulerRules = DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any ("--rules", "ruler") and
        ProcessCommandLine has_any ("rules", "add", "--target")
    or FileName =~ "ruler.exe"
| extend DetectionType = "Ruler_Rules_Attack"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, DetectionType;
union OutlookRuleExec, OutlookUserExec, RulerRules
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: Process Creation Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

False Positives

  • Legitimate Outlook rules that run VBScripts for custom email processing (some organizations use this for compliance or workflow automation)
  • IT-managed rules that launch specific applications when trigger emails are received
  • Help desk automation scripts triggered by Outlook rules for ticket creation
  • Outlook integration with corporate workflow systems that respond to specially formatted emails

Unlock Pro Content

Get the full detection package for T1137.005 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections