NPFS as a Kernel Read/Write Primitive
Disclaimer: This is a technical write-up for exploit developers and most of the topics covered here require and assume previous technical knowledge, but here are the good news: If you are interested in learning take a look at my Windows Kernel Exploitation trainings that will get you where you need to be.
TL;DR
This article is about Exploiting Windows Named Pipe File System (NPFS.sys) internals to turn a kernel memory corruption into an arbitrary kernel read/write primitive.
The central ideas are: NpFr pool allocations and kernel heap manipulation, Corrupted NP_DATA_QUEUE_ENTRY structures, particularly Flink, Fake DQEs and IRPs used to redirect memory access and PeekNamedPipe as a kernel-read mechanism, and finally IRP completion as a kernel-write mechanism.
Let's start from defining what is NPFS?
Named Pipe File System (npfs.sys): It's a core windows driver that enables inter-process communication (IPC) using named pipes between local or networked processes.
Lately I have been favouring the use of NPFS as a way to leverage vulnerabilities into Kernel Read/Write primitives and on this article I am going to try to explain why and what is the Windows Named Pipe File System.
What MSDN says about it: Did you know that the device driver that implements named pipes is actually a file system driver? In fact, the driver's name is NPFS.SYS, for "Named Pipe File System". What you might also find surprising is that its possible to obtain a directory listing of the named pipes defined on a system. This fact is not documented, nor is it possible to do this using the Win32 API. Directly using NtQueryDirectoryFile, the native function that the Win32 FindFile APIs rely on, makes it possible to list the pipes. The directory listing NPFS returns also indicates the maximum number of pipe instances set for each pipe and the number of active instances.
NPFS implements local and remote named-pipe communication and is exposed to applications through ordinary APIs such as:
CreateNamedPipeCreateFileReadFileWriteFilePeekNamedPipe
Microsoft documents the public named-pipe interface and the kernel structures here: Microsoft named-pipe documentation
Internally, data written into a named pipe is represented by entries in a queue belonging to the pipe endpoint. On the tested x64 systems, the relevant structure can be represented conceptually as:
struct NP_DATA_QUEUE_ENTRY {
uint64_t Flink;
uint64_t Blink;
IRP* Irp;
void* SecurityContext;
uint32_t EntryType;
uint32_t QuotaInEntry;
uint32_t DataSize;
uint32_t Reserved;
};
Flink and Blink form the queue linkage. Depending on the entry type, the data is either stored after the queue header or described through an associated IRP.
A normal buffered pipe write is broadly represented as:
The pool tag used by these buffered allocations is commonly observed as NpFr.
This makes named pipes useful for kernel exploitation because an unprivileged process can create large numbers of predictable kernel allocations, control their contents, free selected allocations, and trigger the kernel to traverse them.
NPFS to the rescue: from vulnerability to RW Primitive
The NPFS technique begins with control over a named pipe’s data queue. A memory-corruption type of vulnerability as a prerequisite has already modified one of the queue entries or redirected one of its links. And it becomes useful because named pipes allow a process to create, fill, retain and release kernel allocations with considerable control over their size and lifetime. The structures behind those allocations also describe how pipe data should be handled: where the next queue entry is, how much data it represents and where that data is stored.
Once a queue link has been redirected, an ordinary pipe read causes the kernel to follow it into attacker-controlled memory. The structure found there is treated as the next chunk of pipe data, including its length, backing buffer and associated IRP. By choosing those fields carefully, the read path can retrieve data from a selected kernel address. The same corrupted queue can later be used to complete a prepared IRP, turning the initial corruption into a kernel write primitive. This gives the exploit reusable read and write access while leaving execution inside normal kernel I/O paths.
The queue link may be redirected in several ways. An out-of-bounds write can overwrite the Flink pointer of an adjacent queue entry; a use-after-free can replace a released object with a pipe allocation whose queue fields are under user control, or a limited kernel-write primitive can modify the pointer directly. In some cases, corrupting an entry’s size first exposes a neighboring queue pointer, which is then used to construct the final redirection.
Once the link points to attacker-controlled memory, an ordinary pipe read follows it as though it were the next queued block. The controlled entry supplies the apparent data length, backing buffer and associated IRP.
These fields can be arranged so that the read path returns bytes from a selected kernel address. The same queue can later complete a prepared IRP, converting the initial corruption into a kernel write primitive. The result is reusable kernel read/write access built entirely from normal I/O processing.
A named pipe stores pending data in a linked queue. Each entry describes the amount of data available and, depending on its type, either contains the data directly or refers to an IRP that identifies its backing buffer. If a queue link can be redirected to a fabricated entry, these fields become useful copy descriptors. The pipe read path can then be made to fetch bytes from a selected kernel address. Once that read primitive is available, a pending pipe operation can be located and its IRP adapted so that normal I/O completion copies controlled data to a selected kernel destination.
The result is a data-only kernel read/write primitive built from existing I/O behavior. NPFS continues to perform legitimate queue traversal and IRP completion, the exploit changes the metadata that tells it where the data actually is.
What do we need and what do we get?
- An overwrite into an NPFS data-queue entry.
- A size-field corruption in an NPFS entry.
-
Control of a queue link such as
Flink. -
A use-after-free whose allocation can be reclaimed with an
NpFrobject. - A limited kernel write that can redirect queue traversal.
The central objective is to make a legitimate NPFS queue point to a fake or attacker-controlled NP_DATA_QUEUE_ENTRY.

The fake entry is normally placed in a fixed, page-aligned user-mode mapping. That page is locked into memory so the kernel does not encounter a page fault while treating it as an internal queue object.
The fake entry is not submitted through an NPFS API. NPFS reaches it only because a trusted kernel queue link has already been corrupted.
Requirements
The technique requires more than simply creating a named pipe, it requires an initial memory corruption primitive. The vulnerability itself must provide enough influence to corrupt or replace an NPFS entry.
This could be:
- A pool overflow.
- An out-of-bounds write.
- A use-after-free.
- A pointer overwrite.
- A small arbitrary kernel write.
On Exploit Pack technical write-ups we have covered the following, that uses NPFS:
| Exploit | Initial vulnerability | How NPFS is reached |
|---|---|---|
| HTTP.sys | Adjacent allocation overflow |
HTTP-controlled allocation overruns an NpFr DQE
|
| RDWM1250 | Driver pool overflow |
Vulnerable driver allocation corrupts an adjacent NpFr header and DQE
|
| ViGEmBus | Use-after-free race |
Freed ViGEm object is reclaimed by an equal-sized NpFr allocation
|
Pool-shaping control
For overflow and reclamation variants, the vulnerable allocation and NPFS allocation must land:
- Adjacent to each other, or
- In the same allocator size class, or
- In the same physical pool slot after a free.
This is why the implementations create thousands of named pipes, punch holes, retain selected allocations, pin execution to a processor, and account for LFH delayed-free behavior.
Control of a fake queue entry
The attacker needs a resident user-mode region containing:
- A fake DQE.
- A fake or modified IRP for reading.
- Source values used by the write primitive.
- Supporting status blocks and list entries.
The mapping must be at the address written into the corrupted kernel queue.
Knowledge of build-dependent layouts
The following are not stable public interfaces:
NP_DATA_QUEUE_ENTRY- NPFS CCB fields and queue offsets.
-
_IRPfields. -
Handle-table and
FILE_OBJECTlayouts. - Pool allocator behavior.
The exploit must reduce this dependency by resolving _IRP, EPROCESS, handle-table and file-object offsets dynamically where possible, depending of your build you will have/not have symbols, and by copying a legitimate live IRP as a template.
A way to locate the victim queue
After obtaining an initial read, the exploit needs to identify:
- The victim pipe’s kernel queue head.
- The owning NPFS CCB.
- A helper pipe’s queue.
- One or more live queue entries and IRPs.
Cleanup
A corrupted pipe must be cleaned, NPFS may follow the invalid links or attempt to free a user-mode pointer, producing a bugcheck. The exploit must restore the queue to a state that NPFS can safely drain or destroy, cancel pending operations and only then release the fake mapping.
Constructing the arbitrary-read primitive
The read primitive is the first half, the fake DQE is configured as an IRP-backed data entry like this:
The victim pipe already contains a known amount of legitimate data. We will call this amount the prefix.
The exploit requests:
prefix + number_of_kernel_bytesusingPeekNamedPipe.
NPFS first copies the legitimate prefix. To satisfy the remaining request, it follows the corrupted Flink into the fake DQE. The fake DQE directs NPFS to obtain the remaining bytes from the attacker-selected kernel address, as in the following diagram:
The caller discards the known prefix and retains the final N bytes.
PeekNamedPipe is convenient because it observes data without normally consuming it, allowing the same corrupted queue to perform repeated reads. Microsoft PeekNamedPipe documentation
Bootstrapping a second name pipe
Arbitrary read does not convert into an arbitrary write, but using similar techniques, an a bit more elaborate IRP-completion a write construct can be crafted.
Create a helper pipe to control the write
To put it in simple words, a second named pipe is then created and filled until an additional asynchronous write remains pending.
That pending write provides real kernel objects:
- A legitimate NPFS DQE.
- An outer IRP.
- An associated inner IRP.
- Valid thread, cancel and bookkeeping fields.
At this point we already have an arbitrary-read primitive, we have to use it to locate these objects in runtime kernel memory.
Capture a legitimate IRP template
Instead of constructing every _IRP field from nothing, the exploit reads a live IRP and uses it as a template.
Only the fields relevant to the data copy are changed:
AssociatedIrp/SystemBuffer = source address
UserBuffer = destination address
IoStatus.Information = length
Flags = buffered-I/O completion behavior
The remaining fields retain values consistent with a real IRP from that system.
This is still version-sensitive, which is why we need to use NTOSKernelWalkerLIb to dynamically resolve field offsets.
Queue the controlled inner IRP
The implementations invoke an internal NPFS control operation through NtFsControlFile. This produces a pending queue entry containing an outer IRP and an associated inner IRP.
The exploit then needs to read the helper queue to discover the kernel address of the inner IRP.
Complete the IRP through the corrupted queue
The fake DQE is reconfigured:
Flink = real victim queue head
Irp = controlled inner IRP
QuotaInEntry = write length minus one
DataSize = write length
The exploit then consumes one byte from the victim pipe.
This causes NPFS to process and complete the controlled IRP. During buffered-I/O completion, the I/O manager copies the requested number of bytes from the IRP’s system buffer to its user buffer.
Because both pointers were selected by the exploit:
controlled source → controlled destination
For these exploits, the source is a user-mode value and the destination is a kernel address, producing an eight-byte kernel write.
Unlike PeekNamedPipe, the write trigger consumes data. The implementations therefore decrement their tracked prefix after each write.
How the three entry points differ, with examples
HTTP.sys exploit
HTTP.sys arranges a pool layout containing alternating victim and hole allocations. Crafted HTTP response metadata causes an allocation to extend into the adjacent NPFS entry.
The overflow writes a replacement DQE containing:
- Controlled forward and backward links.
-
A larger
DataSize. - A link to the user-mode fake entry.
The implementation then scans the sprayed pipes for the one whose visible data length has increased. That pipe becomes the victim. See HTTPS.sys Kernel Pool grooming
This is an adjacent-object corruption variant:
HTTP.sys allocation │ adjacent NpFr DQE overflow
RDWM1250 exploit
RDWM1250 uses a vulnerable driver allocation that shares an LFH size class with the target NPFS allocation.
The overflow explicitly reconstructs:
- The adjacent pool header.
-
The
NpFrpool tag. - A replacement DQE.
- The link to the fake user DQE.
- An enlarged data size.
This version highlights a critical pool-exploitation issue: corrupting only the object contents may be insufficient if the overflow also crosses allocator metadata. The overwritten pool header must remain structurally acceptable or the allocator may fail before the NPFS primitive can be used.
RDWM1250 also contains explicit LFH conditioning and delayed-free handling.
ViGEmBus exploit
ViGEmBus is different because there is no adjacent overflow.
A report-submission thread obtains a raw virtual-controller pointer while another thread unplugs and frees the controller. NPFS allocations of the same size are sprayed so one reuses the freed ViGEm slot.
The reclaimed NPFS object is shaped to pass ViGEm’s owner and type checks. A stale virtual dispatch is then redirected to RtlCopyLuid, which copies the first eight bytes of the report into the reclaimed object.
Those eight bytes are deliberately chosen to equal the address of the fake user DQE. The copy therefore replaces the NPFS entry’s Flink with the fake-entry address.
This is a use-after-free reclamation variant:

Once this first queue-link corruption is complete, the remainder of the ViGEmBus exploit uses the same NPFS adapter as the other two.
The workflow of NPFS used for RW primitives
Stripped of the original vulnerabilities, the technique can be described as five phases:
This separation is important because phases C through E are largely reusable. A new vulnerability only needs to solve phases A and B or provide an equivalent way to redirect an NPFS queue.
Comparison with the Windows I/O-ring technique
What the I/O-ring technique is: Windows I/O rings provide an asynchronous I/O submission and completion mechanism. The public API includes:
The exploitation technique targets the kernel IORING_OBJECT, particularly the fields describing preregistered buffers:
IORING_OBJECT
RegBuffersCount
RegBuffers
Normally, buffer registration validates user buffers and copies their descriptions into a trusted kernel allocation. Later I/O operations can reference buffers by index without repeating the original address validation.
If an existing kernel-write primitive changes RegBuffers so it points to a fake attacker-controlled buffer array, indexed I/O-ring requests can describe kernel addresses as though they were legitimately registered buffers.
The technique was presented by Yarden Shafir as a way to amplify a small kernel write or in some cases an arbitrary increment into a full read/write primitive, reference: One I/O Ring to Rule Them All
One imporant distiction is that the direction of the operations are initially reversed:
- Read from a file or pipe into a kernel-address buffer becomes: kernel write.
- Write from a kernel-address buffer into a file or pipe becomes: kernel read.
Named pipes may be used as the transport, but NPFS itself is not corrupted in this technique.
When to use NPFS or I/O rings
| Property | NPFS queue technique | I/O-ring technique |
|---|---|---|
| Corrupted kernel object | NPFS DQE, list or associated IRP | IORING_OBJECT.RegBuffers |
| Typical starting primitive | Overflow, UAF reclaim or pointer corruption | Arbitrary kernel write or increment |
| Is NPFS itself corrupted? | Yes | No, a pipe may only be transport |
| Read mechanism |
PeekNamedPipe traverses fake DQE and IRP
|
I/O-ring write operation sends kernel buffer to pipe/file |
| Write mechanism | Complete crafted buffered IRP | I/O-ring read operation receives data into kernel buffer |
| Pool grooming | Usually substantial | Normally unnecessary after ring setup |
| Required object leak | Queue/CCB discovery, often bootstrapped from overflow |
Address of the IORING_OBJECT
|
| Version sensitivity |
NPFS, pool and _IRP layouts
|
IORING_OBJECT and registered-buffer representation
|
| OS availability | Applicable to older Windows families, subject to layout | I/O-ring APIs are a newer Windows feature |
| Write granularity | Commonly eight bytes per controlled completion | Potentially much larger I/O transfers |
| Reliability | Sensitive to pool layout and queue integrity | Usually simpler once initial pointer writes succeed |
| Cleanup | Repair queue, cancel IRPs, avoid freeing fake DQE | Clear or restore registered-buffer pointer before object destruction |
| Main forensic signal | Large pipe sprays, pool churn, corrupted NPFS queue | Abnormal ring buffer metadata and unusual ring I/O |
When to use I/O Ring and when to use NPFS:
The NPFS technique is primarily a memory-corruption adapter:
Corrupt queue metadata
- obtain arbitrary read
- use a real IRP structure for write
The I/O-ring technique is primarily a write-primitive amplifier:
Existing, but limited kernel write
- corrupt registered-buffer pointer
- legitimate I/O operations become arbitrary read/write
From a NPFS exploitation perspective, a size overwrite, list-link overwrite or same-slot UAF reclaim may be enough to bootstrap the pipes.
I/O rings are generally cleaner once the attacker already has the required write and the ring object’s address. They avoid extensive pool spraying and manual IRP completion, but demand a stronger initial primitive that is not always available.
Similarities and comparisson:
Both techniques are examples of modern data-only kernel exploitation:
- Neither fundamentally requires kernel shellcode, thus data only.
- Neither needs a classic ROP chain, again data only.
- Both reuse valid Windows I/O paths.
- Both convert trusted kernel metadata into attacker-selected source and destination pointers.
- Both work because a pointer was validated or trusted at an earlier stage, then corrupted before later use.
- Both require careful cleanup before the corrupted object is destroyed.
- Both can operate under mitigations that make control-flow hijacking less attractive.
In both cases, the exploit chain is effectively asking the kernel to perform an otherwise legitimate copy with illegitimate metadata.
Reliability and portability
The technique its not universal technique and it has to be adapted per vulnerability, there is no version-independent NPFS primitive and as you can imagine it depends on the build you are running it, as per the kernel module is NPFS of cours, having this in consideration:
The following might change between Windows builds:
- Pool bucket behavior.
- LFH delayed-free policy.
- DQE and CCB layout.
- Queue offsets.
-
_IRPsize and field offsets. - Internal FSCTL behavior.
- Handle-table representation.
- Whether kernel subsystems accept user-address-backed fake objects.
- I/O-ring registered-buffer representation.
A more portable implementation should:
- Resolve symbol-backed layouts dynamically.
- Capture live kernel objects as templates.
- Discover queue offsets through validation rather than one fixed offset.
- Validate every leaked pointer and structure.
- Keep the corrupted object alive until repair succeeds.
- Treat a successful self-test as necessary but not proof of cross-build reliability.
An easy way to resolve these issues would be implementing NTOSKernelWalkerLib in your exploit, or an alternative library for the same purpose.
Can this technique be stopped?
Preventing the original vulnerability remains the strongest defense of course. NPFS is generally operating on memory that should already be trusted.
Additional defense-in-depth opportunities include, but not currently implemented by Microsoft:
- Validating queue-entry types and sizes before traversal.
- Detecting queue pointers outside expected kernel pool ranges.
- Adding consistency checks around NPFS list links.
- Monitoring unusually large named-pipe sprays and repeated fixed-size writes.
- Detecting I/O-ring registered-buffer pointers that reference user space.
- Monitoring unexpected use of internal named-pipe control codes.
-
Expanding Driver Verifier and pool-integrity coverage around queue destruction.
Conclusion
The main conclusion is that a small corruption can become powerful when it reaches a subsystem that already performs general-purpose data movement. NPFS and I/O rings are useful exploitation targets for the same reason they are useful operating-system facilities: both are trusted mechanisms for moving bytes between buffers.



