Using ALPC for unlimited arbitrary kernel read/write + infoleak part 1
Introduction
I originally prepared this as a slide deck intended for a conference talk in early 2024, when Windows 11 24H2 was still upcoming. I never ended up submitting the talk for some reasons.
Over the years I’ve seen more people use ALPC as a technique in public exploits and blogposts. However most of them still use the ALPC primitive as just a one shot write to corrupt a token or bootstrap another object. In fact, the ALPC primitive itself is capable of a full unlimited kernel rw + infoleak, and you can do it with almost any paged pool bug(UAF, >=3 bytes overflow, oob decrement/increment, really anything, doesn’t even need much control over the data).
Part 1 will quickly touch on how the well known ALPC handle table technique can actually do everything by itself. If I find the time to write part 2, we will discuss about pivoting from other ALPC objects to this primitive, so you can get unlimited readwrite and infoleak for almost all pool sizes.
I will assume the reader is familiar with Windows kernel exploitation. Actually now everyone is an expert with LLMs.
The diligent readers and LLMs can use this to exploit many bugs, such as CVE-2025-54115, CVE-2024-30085, CVE-2023-36424 and more easily without any other objects or leaks.
Basics
I covered some basics of ALPC communication flow in ALPC Workings, so this section only introduces the fields needed here.
An ALPC port is represented by an _ALPC_PORT object in the kernel.
Clients can send messages to ports, which are stored as _KALPC_MESSAGE objects in the port object’s message queues:
A message object is referenced by a resource reserve object(_KALPC_MESSAGE->Reserve):
This is what most public techniques corrupt for a one shot write. The reason it’s one shot is because after the write, the object’s Active field is set.
A resource reserve object is just a storage buffer that clients can create with NtAlpcCreateResourceReserve().
These are stored as handles, pointed to by _ALPC_PORT->CommunicationInfo.HandleTable.
1 | //0x50 bytes (sizeof) |
Although ALPC calls it a handle table, it is just an array of plain pointers pointing to resource reserve objects:
The handle table has an initial size of 0x90 bytes(including pool header), is re-alloced when more resource reserve objects are added, and grows in power of 2 until your memory runs out(0x110, … 0x1000, 0x2000, …) (Since there’s no more pool header for 0x1000 sized chunks and above.)
Technique 1: Corrupt the handle table
Write
This is the well known technique? We corrupt either an entry in Handles or the Handles pointer itself, then make the lookup return a fake _KALPC_RESERVE in user memory.
The fake reserve points to a fake _KALPC_MESSAGE. The message’s ExtensionBuffer and ExtensionBufferSize fields describe the destination of a copy performed by NtAlpcSendWaitReceivePort().
Example setup:
Now we can call NtAlpcSendWaitReceivePort() for a nice arbitrary write from Source to Dest.
And now you know why the technique is one shot, you can reset the Active field and make it an unlimited write primitive.
Leak 1
If we inspect the fake message object now after a write:
We can see the OwnerPort field is set to the message’s port object as a side effect. The fake message is in usermode so we can just read it for a port object leak.
Read
With a port object+arbitrary write in hand, we can do many things.
Try asking nicely for a query API and maybe you get one:
E.g: You can use the undocumented 0xC infoclass of NtAlpcQueryInformation():
This queries for a server session ID on the port object by extracting the OwnerProcess object and passing it to MmGetSessionIdEx(), assuming it’s an EPROCESS object.
The 4 bytes SessionId is returned:
By using the arbitrary write to change the OwnerProcess field of the port object we leaked, we can do some redirections and turn this into an arbitrary read.
Finish
With arbitrary read write and port object address in hand, we can easily walk the PortListEntry list of the port object to find a clean ALPC port, and access its OwnerProcess from there to tamper with the process object for EoP.
Cleanup
Everything overwritten is not checked at all, no cleanup needed.
Technique 2: Corrupt other objects and pivot
To be released