Use after free in Bluetooth (CVE-2026-13785)
A use-after-free exists in the macOS Bluetooth socket code because the SDP query listener is deallocated when a local timeout fires, while the macOS IOBluetooth framework still holds a raw pointer to it. A malicious Bluetooth device could delay its SDP response past the timeout and then trigger a callback on the freed object, potentially causing a crash or arbitrary code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 35 days
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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential Use-After-Free (UAF) vulnerability exists in the macOS Bluetooth socket implementation when an SDP query times out. If the timeout fires, the strong reference to the SDPQueryListener delegate is released, immediately deallocating it while the macOS IOBluetooth framework still holds an unsafe_unretained reference to it. When the late callback or internal query completion eventually fires, the OS dispatches a selector to the deallocated object, potentially causing a browser process crash or arbitrary code execution.
Affected files:
device/bluetooth/bluetooth_socket_mac.mm
Estimated timestamp from git blame: 2024-06-13
Problem Description
In device/bluetooth/bluetooth_socket_mac.mm, SDPQueryListener is registered as the target of -[IOBluetoothDevice performSDPQuery:], a legacy macOS system API. Because the macOS IOBluetooth framework dates back to early versions of macOS, it stores its target/delegate using an unsafe_unretained (raw) pointer to avoid strong reference cycles.
Chromium's only strong reference keeping the SDPQueryListener alive is the sdp_query_listener_ instance variable in BluetoothSocketMac (declared as SDPQueryListener* __strong sdp_query_listener_; in the header).
When an SDP query takes longer than the local 10-second watchdog timer, BluetoothSocketMac::OnSDPQueryTimeout() is executed. It clears the callback and resets the listener pointer:
void BluetoothSocketMac::OnSDPQueryTimeout() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!sdp_query_listener_) {
return;
}
auto error_callback = [sdp_query_listener_ takeErrorCallback];
if (error_callback) {
std::move(error_callback).Run(kSDPQueryTimeout);
}
sdp_query_listener_ = nil; // Sole strong reference is dropped, deallocating the listener
}
Resetting sdp_query_listener_ to nil immediately deallocates the SDPQueryListener instance. However, the OS-level SDP query is still running asynchronously in the background. When the query eventually completes (or times out at the system level), the OS Bluetooth framework attempts to invoke -sdpQueryComplete:status: on the deallocated pointer, causing a Use-After-Free inside objc_msgSend.
Since the Device/Bluetooth Service runs inside the unsandboxed Browser process on macOS due to TCC system entitlement constraints, this issue could potentially be leveraged to escape the browser sandbox and execute arbitrary code with browser privileges.
Potential Steps to Trigger the Vulnerability
Note: Our analysis is static and based on code review; we do not currently have an active runtime test environment to execute a proof of concept.
- A user selects a paired, malicious Bluetooth Classic device via a Web Bluetooth/Web Serial chooser prompt.
- The renderer requests a connection, initiating
BluetoothSocketMac::Connectand dispatching[device performSDPQuery:sdp_query_listener_]with a 10-second local watchdog timer. - The malicious Bluetooth device intentionally delays responding to the SDP query for more than 10 seconds.
- The 10-second timer expires, and
BluetoothSocketMac::OnSDPQueryTimeoutdrops the reference, immediately deallocating theSDPQueryListenerobject under ARC. - The attacker attempts to reclaim the freed memory layout by spraying the heap (e.g., via Mojo or other browser allocations) to establish a fake
isapointer and method cache. - The malicious Bluetooth device finally sends the SDP response, prompting the OS to call
-sdpQueryComplete:status:on the dangling target pointer, triggering a control flow hijack.
Suggested Remediation
Since macOS does not provide a reliable API to cancel a pending SDP query once dispatched to IOBluetoothDevice, the SDPQueryListener must not be deallocated until the OS callback is received.
To safely resolve this:
- When a timeout occurs, clear the internal references to prevent processing the callback, but do not immediately deallocate the listener.
- Have the
SDPQueryListenerhold a strong self-reference (__strong id selfKeepAlive = self;) when it is orphaned/detached from the C++ socket. - Release this self-reference at the very end of
sdpQueryComplete:status:, ensuring that the object is safely kept alive until the OS is done interacting with it.
Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
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 sole strong reference to the SDPQueryListener is set to nil on timeout, deallocating it while the macOS IOBluetooth framework still holds an unsafe_unretained pointer to it.
Impact
This could potentially be leveraged to escape the browser sandbox and execute arbitrary code with browser privileges, though the analysis is static and no proof of concept was run.
What the attacker needed
MacOS with Bluetooth; user selects a malicious Bluetooth device; device delays SDP response over 10 seconds
The fix
The listener should be kept alive until the OS callback arrives, for example by holding a strong self-reference that is released at the end of the completion callback.
How it was found
- A user selects a paired, malicious Bluetooth Classic device via a chooser prompt.
- The renderer requests a connection, which starts an SDP query with a 10-second watchdog timer.
- The malicious device delays its SDP response for more than 10 seconds.
- The timer expires and the listener object is deallocated.
- The attacker sprays the heap to try to reclaim the freed memory.
- The device finally sends its SDP response, causing the OS to call a method on the dangling pointer.
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 an object but keeps using it later, that is called a use-after-free. Here, a timer gives up on a Bluetooth query and throws away the object that was waiting for the answer, but the operating system still has a note pointing at that object. When the late answer arrives, the system calls into memory that no longer belongs to it, which can crash the browser or let an attacker run their own code.
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.