Use after free in Device (CVE-2026-13869)
The SerialPortImpl destructor unmaps a Mojo data pipe's shared memory while a Windows overlapped read may still be pending, allowing the kernel to write serial data into a reallocated attacker-controlled object. This could bypass user-mode mitigations and lead to a sandbox escape.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 3 months
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: On Windows, destroying a SerialPortImpl object synchronously unmaps its Mojo data pipe shared memory while an overlapped ReadFile operation may still be pending in the kernel. This can result in the Windows kernel writing serial data into a newly allocated, attacker-controlled object at the same virtual address, bypassing user-mode mitigations like MiraclePtr. This potential write-after-free vulnerability in the browser process could lead to a sandbox escape.
Affected files:
services/device/serial/serial_port_impl.ccservices/device/serial/serial_io_handler_win.ccservices/device/serial/serial_io_handler.ccservices/device/serial/serial_port_impl.h
Estimated timestamp from git blame: 2019-08-21
Background
When a renderer reads from a serial port using the Web Serial API, the browser process (SerialPortImpl) handles the data transfer. To avoid unnecessary memory copies, SerialPortImpl uses mojo::DataPipeProducerHandle::BeginWriteData to get a direct pointer to the Mojo data pipe's shared memory buffer. It passes this pointer directly to the OS-level read function via SerialIoHandler::Read.
On Windows, SerialIoHandlerWin::ReadImpl passes this user-mode virtual address to the ReadFile API along with an OVERLAPPED structure to initiate an asynchronous read. The Windows kernel's I/O manager saves this pointer in the resulting IRP (Irp->UserBuffer) and returns ERROR_IO_PENDING.
The Vulnerability
A potential Use-After-Unmap (Write-After-Free) vulnerability exists in the SerialPortImpl destructor because it fails to ensure that the Windows kernel has finished using the data pipe's memory before unmapping it.
When a compromised renderer abruptly closes the SerialPort Mojo remote, SerialPortImpl is synchronously deleted on the browser's IO thread. The destructor does the following:
- Calls
io_handler_->Close(), which on Windows callsPurgeComm(..., PURGE_RXABORT)to cancel the pending read. - Crucially,
PurgeCommreturns immediately without waiting for the kernel or serial driver to finish processing the IRP abort or for theOnIOCompletedcallback to fire. - The destructor then completes, destroying the
out_stream_member (mojo::ScopedDataPipeProducerHandle). - Destroying the data pipe handle synchronously unmaps the shared memory region (
UnmapViewOfFile) from the browser's virtual address space.
At this point, the kernel still has an IRP pointing to the now-unmapped virtual address. When the IRP eventually completes (even as aborted, or if data arrived just prior to the abort), the kernel's I/O manager executes a special kernel APC to copy the received serial data into the original user-mode virtual address. If an attacker has reallocated that virtual address, the kernel will blindly overwrite the new object, bypassing user-mode memory protections like MiraclePtr (base::raw_ptr).
Note: The developers recognized this exact danger in SerialPortImpl::Flush (serial_port_impl.cc:131-136), where they explicitly delay resetting out_stream_ if IsReadPending() is true, noting that io_handler_ still holds a pointer into the shared memory. This safety check is missing from the destruction path.
Suggested Exploitation Steps
Note: These are potential steps. Our tooling agent does not currently have the ability to run code or provide a working Proof-of-Concept.
- Prerequisite: A compromised renderer gains Web Serial API permissions (either through user interaction or by chaining another bug to spoof permissions).
- Trigger I/O: The renderer opens a serial port and initiates a continuous read operation, providing a large Mojo data pipe.
- Abrupt Disconnect: The renderer abruptly closes the Mojo connection while the serial device is actively sending data.
- Heap Grooming: Immediately after closing the connection, the renderer spams IPC messages (e.g., creating new Blobs or Data Pipes) designed to allocate objects in the browser process of the exact same size as the unmapped data pipe buffer.
- Memory Corruption: The OS reallocates the freed virtual address to one of the attacker's new objects. Shortly after, the kernel I/O manager completes the pending serial IRP and copies the hardware data directly into the attacker's object.
- Code Execution: By carefully crafting the serial data (e.g., using a loopback device or predictable protocol data) and grooming the heap with objects containing function pointers or vtables, the attacker hijacks execution in the browser process, escaping the sandbox.
Proposed Fix
The destruction of out_stream_ (and in_stream_) must be delayed until SerialIoHandler guarantees that no overlapped I/O operations are pending.
One approach is to have SerialPortImpl refrain from destroying the Mojo handles in its destructor if I/O is pending. Instead, it could transfer ownership of the handles to SerialIoHandler itself, or to a callback bound to the CancelRead/CancelWrite completion, ensuring the memory remains mapped until the Windows message pump fires OnIOCompleted.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The destructor of SerialPortImpl destroys the Mojo data pipe handle (unmapping shared memory) without waiting for pending overlapped I/O to complete, unlike the Flush method which has a safety check.
What the attacker needed
Compromised renderer; Web Serial API permissions
The fix
The destruction of out_stream_ and in_stream_ should be delayed until SerialIoHandler guarantees no overlapped I/O operations are pending, for example by transferring ownership of the handles to SerialIoHandler or to a completion callback.
How it was found
- A compromised renderer gains Web Serial API permissions.
- The renderer opens a serial port and initiates a continuous read operation.
- The renderer abruptly closes the Mojo connection while the serial device is sending data.
- The renderer spams IPC messages to allocate objects of the same size as the unmapped buffer.
- The kernel completes the pending serial IRP and copies data into the attacker's object.
- The attacker hijacks execution by crafting serial data and grooming the heap.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program frees memory, it should ensure no other part of the system is still using it. Here, the browser frees a buffer while the Windows kernel might still write to it, so an attacker could trick the kernel into overwriting a new object they control. This could let them run code outside the browser's security sandbox.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.