Use after free in Bluetooth (CVE-2026-13879)
A Bluetooth socket send path wraps a Mojo shared-memory pointer in a non-owning buffer and hands it to an asynchronous background thread. If the Mojo data pipe is closed while the write is pending, the memory is unmapped and the thread can read and transmit reallocated browser memory to an attacker-controlled Bluetooth device.
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. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the security team.
Overview: A Use-After-Unmap vulnerability exists in device/bluetooth/Socket when sending data over a Bluetooth socket. The browser wraps a Mojo shared memory pointer in a non-owning net::WrappedIOBuffer and passes it to an asynchronous socket thread, leading to a potential information leak if the Mojo data pipe is closed while the write is pending.
Affected files:
device/bluetooth/socket.ccdevice/bluetooth/bluetooth_socket_net.cc
Estimated timestamp from git blame: 2024-06-13
Mechanism
In device/bluetooth/socket.cc, Socket::SendMore() reads outgoing data from a Mojo data pipe. It calls send_stream_->BeginReadData(), which returns a base::span pointing directly into Mojo Core's underlying shared memory ring buffer.
This span is then wrapped in a net::WrappedIOBuffer and passed to bluetooth_socket_->Send() for asynchronous transmission:
void Socket::SendMore() {
// ...
MojoResult result = send_stream_->BeginReadData(MOJO_WRITE_DATA_FLAG_NONE, pending_read_buffer);
// ...
std::string_view chars = base::as_string_view(pending_read_buffer);
bluetooth_socket_->Send(base::MakeRefCounted<net::WrappedIOBuffer>(chars),
chars.size(), ...);
}
net::WrappedIOBuffer is explicitly designed as a non-owning wrapper and is documented as "ONLY safe for synchronous use." However, on platforms using BluetoothSocketNet (such as Linux and ChromeOS), the Send() method queues the request and posts a task to a background socket_thread_ to perform the blocking I/O.
The Vulnerability
Because the WrappedIOBuffer is passed across threads for an asynchronous operation, its lifetime outlives the synchronous scope of SendMore(). If the Mojo data pipe consumer handle (send_stream_) is reset before the background thread completes the socket write, Mojo Core will immediately and synchronously unmap (munmap) the shared memory ring buffer from the browser's address space.
Because this memory is allocated via mmap rather than PartitionAlloc, it is not protected by MiraclePtr (BackupRefPtr). The background socket_thread_ retains a dangling pointer inside the WrappedIOBuffer parked in net::SocketPosix::write_buf_.
Potential Attack Scenario
- An attacker compromises a process with access to
device::mojom::Adapter(e.g., the utility process handling Nearby Share on ChromeOS). - The attacker uses
ConnectToServiceInsecurelyto establish a Bluetooth connection to an attacker-controlled remote device, yielding amojom::Socketand its associated data pipes. - The attacker writes up to 64KB (the default pipe capacity) into the send stream.
- The attacker manipulates the remote Bluetooth device to stall L2CAP/RFCOMM network acknowledgments. This fills the kernel's send buffer, causing the browser's background
socket_thread_to hitEWOULDBLOCKduring thesend()call.net::SocketPosixstores theWrappedIOBufferinwrite_buf_and waits for the socket to become writable. - The compromised utility process closes its end of the Mojo send stream.
- The browser's UI thread processes the closure, calls
ShutdownSend(), and resetssend_stream_. This causes Mojo Core to synchronouslymunmapthe 64KB shared memory ring buffer. - The attacker sprays the browser's virtual address space (e.g., via other IPC channels) to reallocate the newly unmapped 64KB block with sensitive browser memory.
- The attacker's remote device resumes sending acknowledgments, unblocking the socket.
- The
socket_thread_wakes up and re-attempts thesend()call using the danglingWrappedIOBuffer, reading up to 64KB of the reallocated, sensitive memory and transmitting it to the attacker's Bluetooth device.
Suggested Fix
To fix this issue, Socket::SendMore() should not use net::WrappedIOBuffer for asynchronous operations. The data obtained from BeginReadData() should be copied into an owning buffer type before being passed to bluetooth_socket_->Send().
Alternatively, if avoiding a copy is strictly necessary, Socket::SendMore() should use a specialized adapter (similar to network::MojoToNetIOBuffer) that takes ownership of a MojoHandle to ensure the Mojo memory remains mapped until the IO buffer is destroyed.
Evaluated with Chrome root at commit: ff3d2b74fa39431785bd60e51463b08fcc71ee33
Results 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
Likely the code passes a non-owning wrapper around Mojo shared memory into an asynchronous socket write, so the buffer can outlive the mapping when the data pipe is reset.
Impact
An attacker could leak up to 64KB of reallocated browser memory to their Bluetooth device, but only after already compromising a process with adapter access.
What the attacker needed
Compromised process with adapter access; attacker-controlled Bluetooth device; ability to stall remote acknowledgements
The fix
The data from the read should be copied into an owning buffer before the asynchronous send, or an adapter that keeps the Mojo memory mapped should be used.
How it was found
- Compromise a process that can reach the Bluetooth adapter interface.
- Connect to an attacker-controlled Bluetooth device to obtain a socket and its data pipes.
- Write up to the pipe capacity into the send stream.
- Stall the remote device so the kernel send buffer fills and the write blocks.
- Close the send stream so the shared memory is unmapped, then spray the address space.
- Resume acknowledgements so the background thread sends the dangling buffer contents.
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 the browser sends data over Bluetooth, it briefly borrows a piece of shared memory instead of making its own copy. A background thread keeps using that borrowed memory after the original owner has freed it, so it can end up sending whatever new data lands in that same spot. This is called a use-after-free: using memory after it has been released.
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.