One Bool. Six Shells. AMSI's Design Problem.
Score: 9/10

One Bool. Six Shells. AMSI's Design Problem.

Analysis of six bypass techniques targeting the Windows Anti-Malware Scan Interface (AMSI) in PowerShell 5.1 and 7 using reflection, memory patching, and IL emission.

Executive Summary

This research details six distinct methods to bypass the Windows Anti-Malware Scan Interface (AMSI), enabling the execution of malicious payloads such as 'Invoke-PowerShellTcp' even with Windows Defender real-time protection enabled. The core vulnerability stems from a shared-process architecture where the scanner and the code it evaluates reside in the same memory space, allowing co-privileged script execution to manipulate scanner internals.

The bypasses range from simple reflection to manipulate 'amsiInitFailed' boolean flags in .NET Framework to more complex techniques like JIT heap patching and DynamicMethod IL emission in PowerShell 7. Notably, some methods exploit the 'fail-open' design of AMSI where native errors (e.g., resulting from a nulled 'pAppName' pointer) default to treating content as clean.

Organizations rely on AMSI as a primary defense against script-based attacks; however, this research demonstrates that signature-based detection is insufficient. Effective mitigation requires structural controls like Constrained Language Mode (CLM), Windows Defender Application Control (WDAC), or Hardware-enforced Stack Protection to prevent the unauthorized memory and reflection operations these bypasses require.

Key Details

Threat Name

Windows AMSI Bypass Techniques

Affects

—

Adversary

—

Malware/Tools

Invoke-PowerShellTcp

Report Score

9out of 10
Quality Score
Excellent
IOC Quality5
TTP Details9
Detection Guidance9
Enterprise Relevance8
Clarity & Structure10
Technical Depth10

Sources