You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Rule Tuning] PowerShell Script with Windows Defender Tampering Capabilities: misses "-DisableRealtimeMonitoring" (analyzer keeps the leading dash) #7272
False Negatives - Enhancing detection of true threats that were previously missed.
Description
The rule misses the most common way of running this technique: Set-MpPreference -DisableRealtimeMonitoring $true.
powershell.file.script_block_text in logs-windows.powershell* uses powershell_script_analyzer, which keeps a leading hyphen on parameter names. _analyze on a current backing index:
POST .ds-logs-windows.powershell-default-*/_analyze
{ "field": "powershell.file.script_block_text",
"text": "Set-MpPreference -DisableRealtimeMonitoring $true" }
returns the tokens set-mppreference, -disablerealtimemonitoring, true.
The rule lists the parameters as unquoted KQL terms (DisableRealtimeMonitoring or DisableIOAVProtection or ...). Those are searched as disablerealtimemonitoring, which does not equal the stored token -disablerealtimemonitoring. So the rule only fires when the name appears without a dash (for example $p.DisableRealtimeMonitoring or a splatting hashtable), and not for the normal command-line form attackers and admins actually type.
We confirmed this with rule preview: a 4104 script block containing Set-MpPreference -DisableRealtimeMonitoring $true -DisableIOAVProtection $true (non-SYSTEM user) produced no alert.
Suggested fix: also match the quoted dash form of each parameter, for example:
powershell.file.script_block_text: (
DisableArchiveScanning or "-DisableArchiveScanning" or
DisableBehaviorMonitoring or "-DisableBehaviorMonitoring" or
...
DisableRealtimeMonitoring or "-DisableRealtimeMonitoring" or
...
HighThreatDefaultAction or "-HighThreatDefaultAction"
)
With that change the same script block alerts in preview, the existing S-1-5-18 exclusion still applies, and 30 days of real PowerShell logs in our environment produced no new matches (no extra noise).
We checked the other KQL rules on script_block_text for the same issue. Terms such as API names (VirtualAlloc, MiniDumpWriteDump), $variables and quoted strings tokenize cleanly, so this seems limited to rules that match PowerShell parameter names. Potential Invoke-Mimikatz PowerShell Script also lists DumpCreds/DumpCerts, but it still fires on the script body ([Switch]$DumpCreds) and on the sekurlsa:: style commands, so it is not affected in practice.
Activity