You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Named Pipe IPC Abuse & MITM (DLL Injection, API Hooking, PID Validation Bypass)
126
+
127
+
Named-pipe hardened services can still be hijacked by instrumenting the trusted client. Tools like [pipetap](https://sensepost.com/blog/2025/pipetap-a-windows-named-pipe-proxy-tool/) drop a helper DLL into the client, proxy its traffic, and let you tamper with privileged IPC before the SYSTEM service consumes it.
128
+
129
+
### Inline API hooking inside trusted processes
130
+
- Inject the helper DLL (OpenProcess → CreateRemoteThread → LoadLibrary) into any client.
131
+
- The DLL Detours `ReadFile`, `WriteFile`, etc., but only when `GetFileType` reports `FILE_TYPE_PIPE`, copies each buffer/metadata to a control pipe, lets you edit/drop/replay it, then resumes the original API.
132
+
- Turns the legitimate client into a Burp-style proxy: pause UTF-8/UTF-16/raw payloads, trigger error paths, replay sequences, or export JSON traces.
133
+
134
+
### Remote client mode to defeat PID-based validation
135
+
- Inject into an allow-listed client, then in the GUI choose the pipe plus that PID.
136
+
- The DLL issues `CreateFile`/`ConnectNamedPipe` inside the trusted process and relays the I/O back to you, so the server still observes the legitimate PID/image.
137
+
- Bypasses filters that rely on `GetNamedPipeClientProcessId` or signed-image checks.
138
+
139
+
### Fast enumeration and fuzzing
140
+
-`pipelist` enumerates `\\.\pipe\*`, shows ACLs/SIDs, and forwards entries to other modules for immediate probing.
141
+
- The pipe client/message composer connects to any name and builds UTF-8/UTF-16/raw-hex payloads; import captured blobs, mutate fields, and resend to hunt deserializers or unauthenticated command verbs.
142
+
- The helper DLL can host a loopback TCP listener so tooling/fuzzers can drive the pipe remotely via the Python SDK.
143
+
144
+
```bash
145
+
pip install pipetap
146
+
```
147
+
148
+
```python
149
+
import pipetap
150
+
client = pipetap.Client(("127.0.0.1", 47001))
151
+
client.write(b"OP\x00\x01...")
152
+
```
153
+
154
+
Combine the TCP bridge with VM snapshot restores to crash-test fragile IPC parsers.
155
+
156
+
### Operational considerations
157
+
- Named pipes are low-latency; long pauses while editing buffers can deadlock brittle services.
158
+
- Overlapped/completion-port I/O coverage is partial, so expect edge cases.
159
+
- Injection is noisy and unsigned, so treat it as a lab/exploit-dev helper rather than a stealth implant.
160
+
125
161
## Troubleshooting and gotchas
126
162
- You must read at least one message from the pipe before calling ImpersonateNamedPipeClient; otherwise you’ll get ERROR_CANNOT_IMPERSONATE (1368).
127
163
- If the client connects with SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION, the server cannot fully impersonate; check the token’s impersonation level via GetTokenInformation(TokenImpersonationLevel).
128
164
- CreateProcessWithTokenW requires SeImpersonatePrivilege on the caller. If that fails with ERROR_PRIVILEGE_NOT_HELD (1314), use CreateProcessAsUser after you already impersonated SYSTEM.
129
165
- Ensure your pipe’s security descriptor allows the target service to connect if you harden it; by default, pipes under \\.\pipe are accessible according to the server’s DACL.
130
166
131
-
## Detection and hardening
132
-
- Monitor named pipe creation and connections. Sysmon Event IDs 17 (Pipe Created) and 18 (Pipe Connected) are useful to baseline legitimate pipe names and catch unusual, random-looking pipes preceding token-manipulation events.
133
-
- Look for sequences: process creates a pipe, a SYSTEM service connects, then the creating process spawns a child as SYSTEM.
134
-
- Reduce exposure by removing SeImpersonatePrivilege from nonessential service accounts and avoiding unnecessary service logons with high privileges.
135
-
- Defensive development: when connecting to untrusted named pipes, specify SECURITY_SQOS_PRESENT with SECURITY_IDENTIFICATION to prevent servers from fully impersonating the client unless necessary.
136
-
137
167
## References
138
-
- Windows: ImpersonateNamedPipeClient documentation (impersonation requirements and behavior). https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-impersonatenamedpipeclient
139
-
- ired.team: Windows named pipes privilege escalation (walkthrough and code examples). https://ired.team/offensive-security/privilege-escalation/windows-namedpipes-privilege-escalation
-[ired.team: Windows named pipes privilege escalation](https://ired.team/offensive-security/privilege-escalation/windows-namedpipes-privilege-escalation)
170
+
-[pipetap – a Windows named pipe proxy tool](https://sensepost.com/blog/2025/pipetap-a-windows-named-pipe-proxy-tool/)
0 commit comments