Use after free in Bluetooth (CVE-2026-79219)
A use-after-free vulnerability exists in BluetoothSocketFloss::DoConnectionStateChanged because running the pending listen callback can synchronously release the last reference to the socket, causing the object to be deleted while its method is still executing. An attacker could potentially trigger memory corruption or instability in the browser process by closing a Bluetooth socket at the right moment.
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. 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 vulnerability exists in BluetoothSocketFloss::DoConnectionStateChanged because invoking the pending listen callback can synchronously release the final reference to the socket. If the socket is deleted during the callback, subsequent code in the method attempts to access and modify member variables of the destroyed object. This could potentially lead to memory corruption or instability in the browser process.
Affected files:
device/bluetooth/floss/bluetooth_socket_floss.cc
Estimated timestamp from git blame: 2023-09-01
Root Cause Analysis
BluetoothSocketFloss (defined in device/bluetooth/floss/bluetooth_socket_floss.h) is a reference-counted thread-safe object. During the asynchronous socket setup phase, the final strong reference to a BluetoothSocketFloss instance may be held within pending_listen_ready_callback_.
Inside BluetoothSocketFloss::DoConnectionStateChanged (located in device/bluetooth/floss/bluetooth_socket_floss.cc), the class executes this callback:
void BluetoothSocketFloss::DoConnectionStateChanged(
FlossSocketManager::ServerSocketState state,
FlossSocketManager::FlossListeningSocket socket,
FlossDBusClient::BtifStatus status) {
if (!listening_socket_info_) {
listening_socket_info_ = socket;
}
if (pending_listen_ready_callback_) {
std::move(pending_listen_ready_callback_).Run(); // <--- Potential synchronous destruction of |this|
}
is_accepting_ = false; // <--- Use-After-Free write
if (state == FlossSocketManager::ServerSocketState::kReady &&
status == FlossDBusClient::BtifStatus::kSuccess) {
FlossDBusManager::Get()->GetSocketManager()->Accept(
listening_socket_info_->id, std::nullopt, // <--- Use-After-Free read
base::BindOnce(&BluetoothSocketFloss::CompleteAccept,
weak_ptr_factory_.GetWeakPtr()));
return;
}
...
}
Because the callback is run synchronously, if the owner or the caller of the socket releases their reference during the callback execution (for example, if an extension closes the socket prematurely), the reference count of the BluetoothSocketFloss instance can drop to zero. This triggers immediate synchronous deletion of this. When control returns to DoConnectionStateChanged, the function continues to execute, performing a write (is_accepting_ = false) and reading from listening_socket_info_, which results in a use-after-free condition.
Potential Trigger Scenario
Note: These are potential steps derived from static analysis of the codebase, as our environment does not support dynamic execution.
- An application or extension creates a Bluetooth socket and requests to listen on a service via
listenUsingRfcommorlistenUsingL2cap. - The system initiates the asynchronous D-Bus call, storing the completion callbacks.
- The application immediately requests to close or release the socket before the D-Bus response is fully processed, removing the external references to the socket.
- When the Floss daemon responds,
DoConnectionStateChangedis invoked on the UI thread. At this point, the callback stored inpending_listen_ready_callback_holds the last remaining strong reference. - Moving and running
pending_listen_ready_callback_destroys the reference inside the callback's scope. If the callback resolves the request by noticing the socket has been closed or removed from the active registry, the reference count drops to 0, destroying the socket object. - Control returns to
DoConnectionStateChanged, leading to member variable access on the deleted object.
Recommended Remediation
To prevent the object from being destroyed while its own method is on the call stack, acquire a strong reference to this at the beginning of DoConnectionStateChanged. This keeps the object alive until the function scope exits, regardless of any synchronous reference drops during the callback execution.
void BluetoothSocketFloss::DoConnectionStateChanged(
FlossSocketManager::ServerSocketState state,
FlossSocketManager::FlossListeningSocket socket,
FlossDBusClient::BtifStatus status) {
scoped_refptr<BluetoothSocketFloss> self(this); // Protects |this| from deletion
if (!listening_socket_info_) {
listening_socket_info_ = socket;
}
...
}
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.
Raised in root component due to access or custom field issues on 1131776
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 method runs a callback that can drop the last reference to the object, deleting it synchronously, and then continues to access member variables without holding a strong reference.
Impact
This could potentially lead to memory corruption or instability in the browser process.
What the attacker needed
Ability to create a Bluetooth socket; ability to close the socket before D-Bus responds; Floss Bluetooth daemon present
The fix
The object should be kept alive by acquiring a strong reference to itself at the start of DoConnectionStateChanged, so it cannot be destroyed while its method is on the call stack.
How it was found
- An application or extension creates a Bluetooth socket and requests to listen on a service.
- The system starts the asynchronous D-Bus call and stores the completion callbacks.
- The application closes or releases the socket before the D-Bus response is processed.
- When the Floss daemon responds, DoConnectionStateChanged runs and the pending callback holds the last strong reference.
- Running the callback drops the reference count to zero, destroying the socket object.
- Control returns to DoConnectionStateChanged, which then accesses member variables of the deleted object.
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.
A use-after-free happens when a program deletes an object from memory but then keeps using it, like reading a note after shredding it. Here, a Bluetooth socket object can be destroyed while one of its own functions is still running, so the function then reads and writes memory that no longer belongs to it. This can crash the browser or, in theory, let an attacker corrupt memory.
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.