← back to theory
Evasion

Modern AMSI & ETW Bypasses — Why They Still Work

Two pieces of Windows instrumentation stand between an attacker's script or in-memory tool and the defender who wants to see it: AMSI, which inspects content as it is about to run, and ETW, which records what the runtime does. Between them they are the backbone of host-based detection for PowerShell and .NET activity — and both can be switched off from inside the very process they are meant to watch. This page builds the whole picture end to end: what each one does, why both are bypassable, how the techniques evolved as defenders caught each generation, how an operator assembles and runs the chain without tripping an alarm, what silencing both actually achieves, and what still catches it.

It uses the real names where a name is load-bearing — AmsiScanBuffer, EtwEventWrite, debug registers, a Vectored Exception Handler — because you cannot reason about the chain without them. What it leaves out is the copy-paste layer: exact offsets, byte patches, literal register values and bit-level encodings. The goal is to understand how the chain fits together and why it behaves as it does, not to hand over a recipe. For where this sits among the other evasion surfaces, see Windows Defense Evasion; for the logging channels involved, see Windows Telemetry & PowerShell Logging.

1. The ground: what AMSI and ETW do

You cannot follow the bypasses without first being clear on what is being bypassed. The two systems do opposite but complementary jobs.

1.1 AMSI — the inspection layer

The Antimalware Scan Interface is a bridge. When a scripting engine (PowerShell, VBScript, JScript) or the .NET runtime is about to execute content, it can hand that content — the actual script text or the bytes of an assembly — to AMSI to be scanned in memory, at the moment of use. Concretely the engine calls into amsi.dll — the entry points are AmsiScanBuffer and AmsiScanString — which forwards the content to the registered AMSI provider (Defender, or a third-party AV) and returns a verdict. The engine then trusts that verdict: clean content runs, flagged content is refused.

The reason AMSI exists is that attackers had moved off disk. Fileless PowerShell, reflectively-loaded .NET, and heavily-obfuscated one-liners never touch the filesystem, so a file-scanning AV never sees them. AMSI closes that gap by scanning the content the runtime is actually going to execute, however it arrived — which is exactly why neutralising AMSI is step one for most script- or .NET-based tooling.

1.2 ETW — the recording layer

Event Tracing for Windows is the plumbing that carries runtime telemetry. Components act as providers that emit structured events; consumers (the EDR agent, Windows' own logging, a SIEM forwarder) subscribe and forward them. In user mode a provider ultimately emits through EtwEventWrite in ntdll — the single choke point most ETW bypasses target. A great deal of what a blue team relies on flows through here: PowerShell script-block logging via the Microsoft-Windows-PowerShell provider (the familiar Event ID 4104, which records the actual code that ran), and the CLR's Microsoft-Windows-DotNETRuntime provider reporting assembly loads and more.

Where AMSI answers "is this content malicious?", ETW answers "what happened, for the record?" One is a gate, the other is a camera. That distinction is the key to the whole page: an attacker who defeats only the gate still gets filmed; one who defeats only the camera still gets stopped at the gate. The two are silenced together precisely because they cover complementary halves of the same exposure.

2. The shared flaw: a guard standing inside the vault

Neither system is bypassable because of a bug that a patch will fix. They are bypassable because of where they run. Both the AMSI scan and the ETW emission happen inside the same process that is running the attacker's code, in user mode. AmsiScanBuffer lives in amsi.dll; EtwEventWrite lives in ntdll; and the flags that gate them — "is AMSI available?", "is this ETW provider enabled?" — sit in that process's own managed and native memory. All of it is reachable by that process's own code.

A guard posted inside the vault can be bribed by whoever is already in the vault. Every AMSI or ETW bypass is a different way of doing exactly that — and because the weakness is structural, closing one route never closes the category.

This is why the durable answer is never "a better in-process check." It is a vantage point the process cannot reach — the kernel, or telemetry shipped off the host — a theme the rest of the page keeps returning to. The practical consequence for an attacker is a menu of options: influence the state the check consults, rewrite the code of the check, or intercept the check's execution — and, more recently, corrupt the data it relies on or replace the provider behind it. The families below are laid out roughly in the order they appeared, because each answers how the previous one got caught.

3. The bypass families — an arms race, in order

3.1 State tampering — convince the runtime it is switched off

The gentlest approach does not fight the scanner; it removes the reason to call it. In PowerShell the relevant flag is the amsiInitFailed field on the internal AmsiUtils class, which the engine checks before every scan — it means, in effect, "AMSI failed to initialise." If it is set, scanning is skipped entirely: sensible fail-open design so a broken antivirus does not break PowerShell. Set that field (classically, through the runtime's own reflection) and the engine quietly stops scanning for the rest of the session. ETW has the same shape: leave the provider in a state the runtime reads as disabled and it never bothers to call EtwEventWrite at all.

Why this fits a modern environment: it never touches antivirus code and never looks like memory corruption. It uses the runtime's own legitimate features to change a value the runtime itself put there. Its weakness is that the state is fragile — it may not exist yet when the process first starts, and an EDR can reset it. That is why serious tooling treats it as a flag to be held down, re-asserting it before each command, each script, and on a timed cycle, rather than flipping it once and hoping.

"But wouldn't the EDR notice a process that stopped being scanned?" In principle, yes — and that is a real weakness of this family — but it is subtler than counting scans. A clean scan is not normally a logged event, so "this process produced zero scans" is not something most tools baseline; there was never a per-scan record to miss. What is observable is the tamper itself: flipping amsiInitFailed moves AMSI from "initialised and scanning" to "reporting init-failed" mid-life, an anomalous transition that modern AMSI surfaces as tamper telemetry — and, ironically, AMSI scans the very script that tries to set the flag, so the classic one-liners are heavily signatured and often caught before they run. The strongest tell, though, is the mismatch: if script-block logging (Event ID 4104, carried over ETW) still shows the process executing plenty of code while AMSI has gone silent, that contradiction is far louder than silence alone. That is precisely why AMSI is rarely silenced on its own — it is paired with an ETW bypass (§6), so the logs that would expose the gap are closed at the same time.

3.2 Function patching — rewrite the check

The blunter, classic approach reaches into the loaded library and overwrites the first instructions of AmsiScanBuffer (for AMSI) or EtwEventWrite (for ETW) so the function returns immediately — reporting "clean", or emitting nothing. For years this was the default, and it still works wherever nothing is watching memory.

This is also exactly where modern defence caught up, and the details of how it got caught shaped everything after it:

  • The edit is visible. The code loaded in the process no longer matches the code Microsoft shipped on disk. EDRs learned to compare the in-memory bytes of these well-known functions against a known-good copy; any difference is a loud, high-confidence tampering signal.
  • Changing the memory protection is itself a tell. The code region of a DLL is not writable by default, so a patch has to flip its protection (classically with VirtualProtect) and then restore it. A well-made version restores it afterwards, because a lingering writable-and-executable (RWX) code page inside amsi.dll or ntdll is one of the cleaner indicators an EDR hunts for — leaving one defeats the purpose.
  • The kernel can still see it. Even a tidy, restored patch is visible from outside the process: a kernel-mode integrity sensor can hash the touched bytes and notice the change. Silencing a user-mode function does not blind a kernel sensor, and a careful operator treats that as a known limit, not a solved problem.

3.3 Patchless interception — change the outcome, not the code

The current favourite leaves the function's bytes completely untouched, so there is nothing for a memory-versus-disk comparison to find. Instead of rewriting the check, it uses the CPU's hardware breakpoints — set through the per-thread debug registers (DR0–DR3, governed by the DR7 control register) — on the entry of AmsiScanBuffer or EtwEventWrite. When execution reaches that address the CPU raises an exception, and a Vectored Exception Handler (VEH) the process has registered catches it first and causes the call to come back benign — as though the scan returned clean, or the event was written — before execution continues. Because no bytes of amsi.dll or ntdll are modified, it is patchless: the whole manipulation lives in debug registers and an exception handler, not in code. (The internal detail of how the handler shapes that return is exactly the recipe layer this page omits.)

Three properties explain why it is effective, and none of them needs low-level detail:

  • It sidesteps the detection that killed patching. The tampering has moved out of the program's code — which is easy to verify — and into the debug registers and a VEH, i.e. fleeting per-thread state, which a static code-integrity scan does not inspect.
  • It must cover every thread the check can run on. Debug registers are per-thread, and a scripting engine runs its work across several threads, so the breakpoint has to be set on all of them — including threads created later — or a scan slips through on an uncovered thread.
  • Setup order is load-bearing. The VEH must be registered before the hardware breakpoint is armed. Arm the breakpoint with no handler ready and the exception has nowhere to go — the process crashes, which is the loudest possible signal.

This is the method getting the most attention in 2025, and it is already evolving under pressure. Rather than forge the return value, some variants have the VEH shrink the length argument the scanner receives so it inspects effectively nothing and reports clean — same outcome, a different lever. And because arming a breakpoint on another thread goes through a thread-context API that kernel telemetry can watch (see §8), newer variants work to arm it more quietly — a two-handler scheme is one published example. The detail of either is the recipe layer this page omits; the point is that even the current favourite is a moving target, not a settled trick.

3.4 Data-only corruption — invalidate the context, not the code

A newer idea reaches the same end as patching without touching any code at all. AMSI keeps a small context object, created when scanning is initialised, whose header starts with an identifying signature. If that signature is corrupted, amsi.dll treats the context as invalid and short-circuits — returning without really scanning (sources differ on whether the exact result is "clean" or an invalid-argument error, so treat it as version-dependent). The appeal is that only heap data changes, never a code page, so the in-memory-vs-disk integrity checks that catch classic patching (§3.2) see nothing wrong. ETW has the same shape: the modern move is less about patching EtwEventWrite and more about scrubbing the provider's enable state so the runtime reads it as disabled, or reaching past the public function to an internal one that integrity checks are less likely to watch.

3.5 Provider hijacking and removal

AMSI is pluggable: antivirus engines register as AMSI providers, as COM servers listed under HKLM\SOFTWARE\Microsoft\AMSI\Providers. An attacker with the rights to edit that key can point the provider at a COM server that always answers "clean", or simply remove the registration so no provider is consulted at all. Unlike the in-memory tricks, this survives process restarts and even reboots — it is as much persistence as evasion — but it needs administrative privileges and leaves a registry change that monitoring of those keys catches directly. It is the "configure the defence away" option rather than the "fight it in memory" one.

3.6 Hiding the bypass's own footprint

A modern loader does not just run a bypass; it tries to make the bypass itself quiet, because the setup is now what gets caught. Two ideas dominate:

  • Unhooking. EDRs plant inline hooks in the userland copies of ntdll and amsi.dll to watch sensitive calls. Loading a fresh, pristine copy of the library from disk (or from the cached KnownDLLs) over the hooked one removes those hooks, so the bypass's own actions are no longer observed by the EDR's userland sensor.
  • Indirect syscalls. The memory and thread operations a bypass needs can be issued so that execution enters the kernel without passing through the hooked function prologues in ntdll, denying the userland hooks a look at them.

Both only defeat userland visibility, and that limit is the whole story of §8: they do nothing against kernel-sourced telemetry, which is exactly where the state of the art is now caught.

3.7 The methods at a glance

FamilyWhat it manipulatesWhat catches it
State tamperingA flag the runtime consults before scanning / emitting (e.g. amsiInitFailed)AMSI tamper signals; the flag being reset and re-asserted repeatedly
Function patchingThe first bytes of AmsiScanBuffer / EtwEventWriteIn-memory vs on-disk integrity checks; RWX code pages; kernel hashing
Patchless interceptionExecution of the check — a hardware breakpoint (debug registers) + a VEHKernel telemetry on thread-context changes (ETW-TI); debug-register / VEH inspection
Data-only corruptionThe AMSI context signature, or an ETW provider's enable state — heap data, not codeIntegrity checks that also watch key data structures; abnormal/invalid context state
Provider hijack / removalThe registered AMSI provider COM entry under HKLM\…\AMSI\ProvidersRegistry monitoring of the provider keys; an admin-level change
Footprint hiding (unhooking / indirect syscalls)Not a bypass itself — hides the others' userland tracesKernel-sourced telemetry (ETW-TI), which userland unhooking cannot reach

4. Operating it without getting caught

Making a bypass work is the easy part. Making it unremarkable to something looking straight at it is where real tooling spends its effort — and this is the part most write-ups skip, yet it is central to why these techniques survive in instrumented environments. Two ideas capture the discipline without the plumbing.

4.1 Stay applied, and look normal doing it

Because the debug registers are per-thread, the technique re-applies the breakpoint to every thread on a timed cycle, so threads born since the last pass are covered rather than left as a gap a scan can escape through. A refined implementation goes further and uses the remaining debug-register slots for decoy hardware breakpoints — WRITE breakpoints aimed at dead, never-touched pages, so they genuinely never fire — so that a defender enumerating DR0–DR3 sees a plausible, shifting pattern across the slots instead of a single execute breakpoint pinned permanently on AmsiScanBuffer. The real breakpoint hides inside what looks like ordinary debugger churn.

4.2 Tear down cleanly, or give the game away

Cleanup is where clumsy tooling exposes itself, and the ordering is not optional:

  • The debug registers must be cleared before any pages they reference are released — leaving a breakpoint pointed at freed memory is far worse than leaking it, so if clearing fails the decoy pages are deliberately left in place.
  • The background worker that maintains all this is only disposed once it has provably stopped; tearing it down while it might still be running is a reliable way to hang the whole process.
  • Get either wrong and the process crashes or freezes — the single loudest thing an "evasion" technique can do.
Notice where all this care goes: not into defeating the check, but into erasing the traces that would reveal the bypass. That is the tell that the real contest has moved from "can you get past it?" to "can you stay unseen while you do?"

5. The full chain, assembled

Put the pieces in order and a complete in-process evasion chain looks like this. Each stage has a goal, a mechanism (named only in concept), and a cost — the trace it risks leaving — which is what makes the sequence a chain rather than a list: later stages exist to cover for the exposure of earlier ones.

StageGoalWhat it defeats / risks
1. Land & assessRun in a host process with the right access; learn what is watchingNothing yet — but choices here decide how much noise later stages make
2. Blind inspection (AMSI)Make content scanning stop flagging — by state, patch, or interceptionDefeats the gate; risks tamper / integrity signals depending on method
3. Blind recording (ETW)Make the runtime's event stream go quiet for this processDefeats the camera; risks the same integrity signals as a patch would
4. MaintainRe-assert across threads and cycles; keep the debug state looking normalCovers threads/resets that would otherwise re-expose activity
5. ActRun offensive scripts / in-memory .NET, drive the host, move onThe payoff — now largely unscanned and unlogged on this host
6. Tear downClear traps, release resources in the safe order, exit cleanlyAvoids the crash/hang and leftover artefacts that would betray everything

The important structural point is that stages 2–4 are not independent tricks bolted together; they are mutually reinforcing. Blinding AMSI with no plan for ETW means the activity is unscanned but fully logged. Blinding both but failing to maintain across new threads means a later pipeline runs in the clear. Doing all of that but tearing down carelessly turns a quiet operation into a crashed process and a high-fidelity alert. A real chain is only as quiet as its noisiest stage.

6. What combining AMSI and ETW silencing buys an attacker

The two are silenced together because they cover complementary halves of a process's exposure. AMSI is the inspection half — what would flag a malicious script or in-memory tool as it runs. ETW is the recording half — what would leave a log of that activity to review later. Neutralise both inside a process and:

  • tooling that would normally be caught on execution runs without being flagged, because the content is never meaningfully scanned;
  • the activity leaves little of its usual evidence — no script-block logs, no runtime load events — so even a later hunt has less to pivot on;
  • the process becomes a quiet place to stage further work: run offensive .NET in memory, enumerate, move laterally, all while the host-based signals a blue team keys alerts on are muted for that process.

The crucial qualifier — and the reason this is not game over for a defender — is the word process. Every bit of this lives in user mode, inside one process, and only affects what that process reports about itself. It does not touch a kernel sensor. It does not silence telemetry gathered from outside the process. It does nothing to network logs, identity/authentication events, or what other hosts record. An attacker buys local quiet, not true invisibility — which is precisely why mature detection never depends on in-process signals alone.

7. Why this keeps working in modern environments

Lay the families and the operational care side by side and the pattern is unmistakable. Every defensive advance — content scanning, then in-memory integrity checking, then watching debug state — was answered not by beating it head-on but by moving the manipulation somewhere the new detection does not look: from the antivirus engine, to a managed flag, to the function's bytes, to volatile per-thread execution state, and finally to hiding that state inside normal-looking churn. The attacker keeps winning the same structural argument from §2: the check and the code share one process, so whatever a defender can observe from inside that process, the attacker can reach too.

AMSI/ETW bypass is best understood as an arms race over visibility, not a single vulnerability to be patched. The techniques persist because the flaw they exploit is architectural, and the only moves that durably counter them come from outside the process.

8. What actually catches it

Because every technique here lives inside the process, the defences that work are the ones that watch from outside it — the vantage point the bypass cannot reach:

  • Kernel telemetry — the ceiling on all of it. The Microsoft-Windows-Threat-Intelligence provider (ETW-TI) is registered by the kernel itself, so it reports regardless of userland tricks: unhooking and indirect syscalls (§3.6) do not touch it. Crucially, setting a hardware breakpoint on another thread goes through a thread-context change (NtSetContextThread), which ETW-TI surfaces — so the very step that makes the patchless method (§3.3) possible is also what a modern EDR keys on to catch it. This is the vantage point an in-process bypass cannot reach, and it is why the state of the art has a ceiling rather than a clean win.
  • Integrity and memory scanning. Periodically comparing the loaded security functions against their on-disk originals catches the patching family outright, and memory scans can flag the known shapes these bypasses leave behind.
  • Debug-register and handler inspection. An ordinary, non-debugged process whose threads carry non-zero debug registers (DR0–DR3), a hardware breakpoint sitting on AmsiScanBuffer or EtwEventWrite, or a freshly-registered VEH around them, is anomalous — detectable even though no code was altered, and not hidden by the decoy trick once a defender enumerates which function the one execute breakpoint actually covers.
  • Tamper and absence signals. Modern AMSI reports when its own state looks manipulated, and a sudden, unexplained silence from a process that should be emitting script-block or .NET events is itself a detection — missing telemetry is a signal, not a blind spot, if you are looking for it.
  • Breadth and off-host logging. Because the bypass is scoped to one process on one host, shipping logs off the host in real time, and correlating across network, identity and other endpoints, defeats the "local quiet" an attacker bought. Script-block logging forwarded to a SIEM, behavioural rules, and newer PowerShell/.NET hardening all raise the cost of staying silent.

9. The takeaway

AMSI and ETW are a gate and a camera posted inside the room they guard, so anyone already in the room can lean on them — and the techniques for doing so have evolved, step for step, to stay ahead of each new way of noticing. The complete chain is not one clever trick but a disciplined sequence: blind the gate, blind the camera, maintain both quietly, act, and leave no mess. Understanding it that way makes the defensive conclusion obvious — stop trusting signals that live where the attacker already stands, and invest in the kernel-level, cross-host, off-box visibility that the whole chain, by construction, cannot touch.

Related reading