AMSI
AMSISCANBUFFER
PATCHING
REFLECTION
DetectionBlue TeamSOCOctober 12, 2026•9 min read

Detecting AMSI Bypass: Patching, Reflection and Provider Tampering

AMSI is the last chance for your antimalware engine to read a script before it runs. Attackers know that, so the bypass usually arrives before the payload does.

Scroll

The Antimalware Scan Interface lets Defender and other engines inspect PowerShell, VBScript, JScript, .NET assemblies and Office macros after deobfuscation. That makes it a prime target: a one-line bypass blinds script-based detection for the rest of the session. The bypass itself is short, noisy and often copy-pasted, which gives defenders several reliable places to look.

Signals at a Glance

SignalWhereATT&CK
Script block text containing AmsiUtils, amsiInitFailed or AmsiScanBufferPowerShell 4104, MDE PowerShellCommandT1562.001
Write or VirtualProtect against the amsi.dll code section in the same processEDR memory telemetry, ETW Threat-IntelligenceT1562.001
amsi.dll loaded into a process that never loads it, or not loaded where it should beSysmon 7T1562.001
AmsiEnable set to 0 or AMSI provider key deletedSysmon 12/13, registry telemetryT1112
powershell.exe -version 2 downgrade to an engine without AMSISysmon 1, 4688T1059.001

Script-Level Bypasses

The best-known bypasses use .NET reflection to flip the private amsiInitFailed field, or patch AmsiScanBuffer in memory so it returns a clean result. Both need a handful of recognisable tokens at some point, even when the author splits strings. Script block logging records the code after PowerShell has de-obfuscated it, so hunt there first:

// Microsoft Defender XDR (KQL) - AMSI bypass strings in PowerShell script blocks
DeviceEvents
| where ActionType == "PowerShellCommand"
| extend cmd = tostring(parse_json(AdditionalFields).Command)
| where cmd has_any ("AmsiUtils", "amsiInitFailed", "AmsiScanBuffer", "amsiContext", "AmsiOpenSession")
     or cmd matches regex @"(?i)\[Ref\]\.Assembly\.GetType\(.{0,40}Am.{0,6}si"
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, cmd
// tune/validate: security tooling and some admin scripts reference these names legitimately.

Do not rely on string matching alone. Authors concatenate or encode the names, so add a behavioural pair: a PowerShell process that also changes AmsiEnable or starts as version 2. The registry route is quieter and easy to catch:

title: AMSI Disabled via Registry
logsource:
  product: windows
  category: registry_set
detection:
  amsi_enable:
    TargetObject|endswith: '\Software\Microsoft\Windows Script\Settings\AmsiEnable'
    Details: 'DWORD (0x00000000)'
  provider_removed:
    EventType: DeleteKey
    TargetObject|contains: '\Microsoft\AMSI\Providers\'
  condition: amsi_enable or provider_removed
level: high
# tune/validate: confirm your EDR does not itself write these keys during upgrades.

Memory Patching and Process Context

An in-process patch is the hardest variant to log with default Windows telemetry, because the write is a few bytes inside a loaded module. Endpoint products that subscribe to the Microsoft-Windows-Threat-Intelligence ETW provider can see the protection change on the amsi.dll code page. If you run such a product, make sure that alert is routed to the SOC rather than left as informational.

Vetted sources

Start from the SigmaHQ AMSI bypass and script block rules, Elastic’s defense-evasion AMSI detections, Splunk ESCU PowerShell content and the MITRE ATT&CK T1562.001 procedure examples. Atomic Red Team ships safe bypass tests so you can prove each detection fires. Baseline your own environment first — red team tooling and security products reference the same strings.

Build Detections That Fire

Mjolnir Security helps blue teams turn threat intelligence into high-fidelity detections across endpoint, network, identity and cloud telemetry.

Detection EngineeringManaged Detection & ResponseThreat HuntingIncident ResponsePurple Teaming
  • Detection Engineering We build and tune detections mapped to ATT&CK from your own telemetry.
  • Threat Hunting as a Service Hypothesis-driven hunts for the behaviours on this page.
  • 24/7 Incident Response Containment when a detection fires. Call +1 833 403 5875.
Written by: Mjolnir Threat Research (MTAC)  |  Published: October 12, 2026  |  Last reviewed: October 12, 2026