← All posts

Named Pipe Impersonation: How Attackers Escalate to SYSTEM and How to Detect It

Named pipe impersonation lets a service-level process steal a SYSTEM token in seconds. Here's how the attack works and what to audit on every Windows endpoint.

If an attacker already has code running as a low-privilege service account — NETWORK SERVICE, LOCAL SERVICE, or an unprivileged IIS/SQL worker — the shortest path to NT AUTHORITY\SYSTEM often runs through a named pipe. Named pipe impersonation is quiet, requires no exploit, no dropped binary, and no vulnerable driver. It is a feature of the Windows security model working exactly as designed. That is precisely why it keeps working.

What a named pipe actually is

A named pipe is an inter-process communication channel exposed under the \\.\pipe\ namespace. A server process creates the pipe and waits; a client connects and the two exchange bytes. The security-relevant part is a single API call: after a client connects, the server can call ImpersonateNamedPipeClient() and — for the duration of that call — adopt the client's security context on the calling thread.

That is legitimate and useful. A print spooler or an RPC service needs to act on behalf of the caller so it doesn't do privileged work the caller couldn't do themselves. The abuse comes from inverting the trust: if an attacker controls the pipe server, and can coerce a SYSTEM process to connect to it as a client, the server can impersonate SYSTEM and duplicate that token into a fully privileged process.

The attack, step by step

  1. The attacker's service-level process creates a named pipe it controls, e.g. \\.\pipe\srv_<random>.
  2. It coerces a SYSTEM-level component to connect to that pipe. The classic coercion primitives are the various "Potato" techniques — abusing the DCOM/RPC activation service or the BITS/SSPI machinery to trigger an authenticated SYSTEM connection back to a local endpoint the attacker controls.
  3. Once SYSTEM connects as a client, the server calls ImpersonateNamedPipeClient(), then OpenThreadToken() to grab the impersonated SYSTEM token.
  4. It calls DuplicateTokenEx() to turn that impersonation token into a primary token, then CreateProcessWithTokenW() (enabled by SeImpersonatePrivilege, which service accounts hold by default) to spawn a SYSTEM shell.

The whole chain takes a fraction of a second. The single most important precondition is that the attacking account holds SeImpersonatePrivilege — which is exactly why service accounts are the launch pad for this class of attack.

Why EDR and antivirus miss it

There is no malware signature here. ImpersonateNamedPipeClient, DuplicateTokenEx, and CreateProcessWithTokenW are called thousands of times a day by legitimate Windows services. Detection has to reason about context — which account made the call, what pipe was involved, and whether the resulting process lineage makes sense — not about a byte pattern. That is a configuration-and-behavior problem, and it is where a host that continuously audits its own security posture beats a dashboard you check once a quarter.

What to audit on every endpoint

Named pipe impersonation is a privilege-escalation problem, so the defenses are about shrinking the blast radius and lighting up the telemetry:

How WinSentinel helps

WinSentinel treats this as posture, not a one-off scan. On a single machine — free, with all 33 modules and no limits — it enumerates every account holding SeImpersonatePrivilege, flags service accounts running with more privilege than they need, verifies that process-creation and named-pipe auditing are actually turned on, and checks that your patch level closes the known coercion vectors. Because it re-runs on a schedule, drift — a new app pool quietly added as SYSTEM, an audit policy reverted by a GPO change — shows up as a delta instead of a surprise during incident response.

For organizations, the Pro tier rolls those same per-machine findings up across the fleet from a central node: you can answer "which of my 200 endpoints have a non-service account holding impersonation rights?" in one query, and get a drift alert the moment a new one appears. The audit logic is identical on every box; the fleet view is what turns 200 individual answers into a single posture you can act on.

Named pipe impersonation isn't a bug you patch once — it's a privilege model you have to keep honest. The endpoints that stay safe are the ones that check themselves every day, not the ones that got scanned last spring.