Chapter 69

Named Pipes

Named pipe internals, ImpersonateNamedPipeClient privilege escalation, Cobalt Strike's default pipe names, Sysmon Event 17/18, and detection strategies for pipe-based C2.

Scenario

Sysmon Event 17 fires: PipeName = \MSSE-1234-server, Image = C:\Windows\System32\svchost.exe. Default Cobalt Strike pipe name pattern. The analyst checks Event 18 (pipe connected): a rundll32.exe process connected to it. A Cobalt Strike SMB beacon uses named pipes for intra-host C2 communication — the network beacon lives in svchost, and the injected payload in rundll32 communicates with it via pipe. No network connection visible for the payload process. Without named pipe telemetry, this would be invisible.

Named Pipe Internals

Named pipes are a Windows IPC mechanism that works like a bidirectional file. A server creates a pipe, a client connects, and they exchange data. Named pipes have a path in the NT Object Namespace: \\.\pipe\PipeName.


  Named Pipe Lifecycle
  ══════════════════════════════════════════════════════════════════

  Server (e.g., Cobalt Strike beacon)
       │
       │ CreateNamedPipe(
       │   "\\\\.\\pipe\\MSSE-1234-server",  ← the pipe name
       │   PIPE_ACCESS_DUPLEX,
       │   ...,
       │   nMaxInstances = 1
       │ )
       │
       │ ConnectNamedPipe()  ← waits for client
       │
  Client (injected payload) ──────────────────►
       │ CreateFile("\\\\.\\pipe\\MSSE-1234-server", ...)
       │
       │ Connection established
       │ (bidirectional I/O: ReadFile / WriteFile)
       │
  Server can optionally:
  ImpersonateNamedPipeClient()  ← impersonates client's security context
       │ Now running as client's token
       │ If client is SYSTEM, server gains SYSTEM

    

ImpersonateNamedPipeClient

When a server calls ImpersonateNamedPipeClient(), it adopts the security token of the connected client. If a privileged process connects to a pipe created by a lower-privileged attacker, the attacker can impersonate the privileged process.

Why this is a privilege escalation primitive

The attacker creates a pipe named to look legitimate. Tricks a privileged service (running as SYSTEM) into connecting. Calls ImpersonateNamedPipeClient(). Now runs as SYSTEM. This technique is used by several local privilege escalation exploits in Windows. The mitigations are: never run privileged code that connects to user-named pipes, and the SeImpersonatePrivilege token privilege restriction. Token impersonation attacks (Potato family attacks) use this same primitive.

Cobalt Strike Default Pipe Names

Cobalt Strike SMB beacons use named pipes for lateral movement and intra-host C2. Default pipe names (commonly seen in the wild):

Pipe Name PatternCobalt Strike Version / Usage
\MSSE-<4chars>-serverDefault SMB beacon pipe (older default)
\postex_*Post-exploitation jobs (e.g., hashdump, Mimikatz)
\postex_ssh_*SSH post-ex jobs
\status_*Job status pipes
\msagent_*CS agent pipes (newer)
\DserNamePipe*Observed in some CS variants
\ntsvcsUsed by some CS profiles mimicking legitimate pipes
Mental model

Cobalt Strike allows operators to change pipe names via Malleable C2 profiles. The defaults above are just starting points. In mature red teams and APT operations, pipe names are customized to blend in — e.g., mimicking legitimate Windows pipe names like \lsarpc, \svcctl, or \atsvc. This makes rule-by-name insufficient; behavioral rules (pipe created by unusual process, or pipe connected between suspicious process pair) are more robust.

Sysmon Events 17 and 18

Event IDDescriptionKey Fields
17Pipe Created — server creates the pipePipeName, Image (creating process), ProcessId, User
18Pipe Connected — client connects to pipePipeName, Image (connecting process), ProcessId, User

Sigma Rules

YAMLcobalt_strike_pipe_names.yml
title: Cobalt Strike Default Named Pipe Created
status: stable
logsource:
    product: windows
    category: pipe_created
    definition: 'Sysmon Event ID 17'
detection:
    selection:
        EventID: 17
        PipeName|startswith:
            - '\MSSE-'
            - '\postex_'
            - '\postex_ssh_'
            - '\status_'
            - '\msagent_'
    condition: selection
level: critical
tags:
    - attack.execution
    - attack.t1055
YAMLsuspicious_pipe_from_injected.yml
title: Named Pipe Created by Process in Suspicious Path
status: experimental
logsource:
    product: windows
    category: pipe_created
detection:
    selection:
        EventID: 17
        Image|contains:
            - '\AppData\'
            - '\Temp\'
            - '\ProgramData\'
            - '\Users\Public\'
    condition: selection
falsepositives:
    - Some legitimate software in non-standard paths
level: medium

Pipes Over the Network

Named pipes can be accessed remotely over SMB (port 445). Remote pipe access path: \\target\pipe\PipeName. This is how Cobalt Strike SMB beacons communicate between hosts — no new TCP connections from the payload; everything travels inside SMB on port 445 (which is often allowed through internal firewalls).

Detection: Sysmon Event 3 showing SMB (port 445) connection from one host to another + Event 18 on the target showing a connection from a remote source (User field shows remote machine account).

Q & A

Q: Cobalt Strike operators change the default pipe names. How do you build detections that survive pipe name changes?

Focus on behavior, not pipe name: (1) Named pipe created by an unusual process — svchost.exe creating pipes is normal, but svchost.exe creating a pipe AND another process immediately connecting to it from an unusual path is suspicious. Correlate Event 17 (creator) with Event 18 (connector) on the same PipeName within a short time window. (2) Process injection indicators — if Sysmon Event 8 (CreateRemoteThread) or Event 10 (ProcessAccess for injection) preceded the pipe creation, the pipe is likely C2 channel for the injected code. (3) Parent-child pipe anomalies — a process with no known pipe-using functionality creating a pipe. Pipe name IOCs are useful for immediate detection of known tools but must be supplemented with behavioral rules for custom profiles.