Windows Exploitation Tricks: Spoofing Named Pipe Client PID
Summary
While researching the Access Mode Mismatch in IO Manager bug class I came across an interesting feature in named pipes which allows a server to query the connected clients PID. This feature was introduced in Vista and is exposed to servers through the GetNamedPipeClientProcessId API, pass the API a handle to the pipe server and you’ll get back the PID of the connected client. It was clear that there must be some applications which use the client PID for the purposes of security enforcement. However I couldn’t find any first-party applications installed on Windows which used the PID for anything security related. Third-party applications are another matter and other researchers have found examples of using the PID to prevent untrusted callers from accessing privileged operations, a recent example was Check Point Anti-Virus. As relying on this PID is dangerous I decided I should highlight ways of spoofing the PID value so that developers can stop using it as an enforcement mechanism and demonstrate to researchers how to exploit such dangerous checks. A simple example of a security check using the client PID written in C# is shown below. This code creates a named pipe server, waits for a new connection then calls the GetNamedPipeClientProcessId API. If the API call is successful then a call is made to SecurityCheck which performs some verification on the PID. Only if SecurityCheck (highlighted) returns true will the client’s call be handled.
- Published
- Collected
Skip to content