Use after free in USB (CVE-2026-13880)
A race condition in WebUSB on macOS allows a use-after-free of a system-allocated COM object. A compromised renderer could exploit this to escape the sandbox and achieve arbitrary code execution in the browser process.
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 race condition in WebUSB allows a potential Use-After-Free in the browser process on macOS. UsbDeviceHandleImpl::SetConfiguration destroys InterfaceClaimer objects synchronously on the main thread, violating libusb threading expectations. This races with concurrent operations on the blocking task runner, leading to a UAF of a system-allocated COM object.
Affected files:
services/device/usb/usb_device_handle_impl.ccthird_party/libusb/src/libusb/os/darwin_usb.cthird_party/libusb/src/libusb/core.c
Estimated timestamp from git blame: 2024-06-25
Technical Details
A potential Use-After-Free (UAF) vulnerability exists in the WebUSB implementation on macOS, which could allow a compromised renderer to escape the sandbox and achieve arbitrary code execution in the browser process.
Root Cause
The issue stems from a thread-safety violation in services/device/usb/usb_device_handle_impl.cc. The UsbDeviceHandleImpl::SetConfiguration method cancels pending transfers and then synchronously calls claimed_interfaces_.clear() on the main sequence.
When Transfer::Cancel() is called, it immediately drops its reference to the InterfaceClaimer by setting claimed_interface_ = nullptr. Subsequently, clearing the claimed_interfaces_ map drops the final reference to the InterfaceClaimer, causing its destructor ~InterfaceClaimer to run synchronously on the main sequence.
This violates the assumption that InterfaceClaimer destruction (and the underlying libusb_release_interface call) occurs on the blocking_task_runner_. While debug builds catch this via DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_), release builds compile this check out, allowing a blocking libusb call to execute on the main sequence.
Race Condition and Use-After-Free
A compromised renderer can trigger a race condition by concurrently invoking SetInterfaceAlternateSetting and SetConfiguration via Mojo IPC:
- Blocking Thread:
SetInterfaceAlternateSettingcorrectly posts a task to theblocking_task_runner_, which callslibusb_set_interface_alt_setting(third_party/libusb/src/libusb/core.c). - Lock Release: Inside
libusb_set_interface_alt_setting, the code acquires the device lock, performs validation, and then explicitly releases the lock before calling the OS-specific backend. - Darwin Backend (Blocking Thread): Execution enters the macOS backend
darwin_set_interface_altsetting(third_party/libusb/src/libusb/os/darwin_usb.c). It callsSetAlternateInterfaceon the COM proxy, triggering a synchronous Mach IPC call that blocks waiting for the USB device. - Main Sequence: Concurrently, the browser processes the
SetConfigurationIPC. As described above, it drops all references to theInterfaceClaimer, triggeringlibusb_release_interfaceon the main sequence. - Darwin Backend (Main Sequence): Because the lock was released in Step 2,
libusb_release_interfacere-acquires it and enters the backenddarwin_release_interface. This callsUSBInterfaceClose, which immediately aborts the pending operation on the blocking thread. It then callsRelease()on the interface COM proxy, freeing the underlying memory to the system malloc heap. - UAF (Blocking Thread): The aborted
SetAlternateInterfacecall wakes up the blocking thread, which then proceeds to unconditionally callget_endpoints(). Insideget_endpoints, it fetches the now-freed interface pointer and attempts a virtual function call (GetNumEndpoints), triggering the Use-After-Free.
Impact and Exploitability
Because the COM proxy is allocated by macOS IOKit/CoreFoundation using the system malloc, this memory is not protected by Chrome's PartitionAlloc or MiraclePtr (BackupRefPtr).
An attacker exploiting this would follow these suggested steps:
- Obtain WebUSB access to a device (either via existing permission or a malicious device).
- Using a compromised renderer, send a Mojo IPC to claim an interface.
- Send
SetInterfaceAlternateSettingfollowed immediately bySetConfigurationto trigger the race. - During the race window (between
Release()on the main thread andGetNumEndpoints()on the blocking thread), perform a heap spray via other IPCs or WebUSB operations to overwrite the freed system malloc chunk with attacker-controlled data. - The virtual call in
GetNumEndpointsdereferences the attacker-controlled vtable, resulting in arbitrary code execution (RCE) in the browser process.
Note: These are potential steps; our tooling has not yet executed a live proof-of-concept.
Suggested Fix
Transfer::Cancel()should not immediately clearclaimed_interface_ = nullptr. The transfer should retain the reference until it is properly cleaned up inTransferCompleteviaDeleteSoonon the blocking thread.- In
UsbDeviceHandleImpl::SetConfiguration, instead of synchronously callingclaimed_interfaces_.clear(), move the interfaces to the blocking thread usingblocking_task_runner_->ReleaseSoon, mirroring the correct pattern used inUsbDeviceHandleImpl::CloseandUsbDeviceHandleImpl::ReleaseInterface.
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 root cause is that `UsbDeviceHandleImpl::SetConfiguration` destroys `InterfaceClaimer` objects synchronously on the main thread, violating libusb's threading expectations and racing with concurrent operations on the blocking task runner.
Impact
A compromised renderer could escape the sandbox and achieve arbitrary code execution in the browser process, though the report notes that a live proof-of-concept has not been executed.
What the attacker needed
WebUSB access to a device; compromised renderer
The fix
The fix should ensure that `Transfer::Cancel()` does not immediately clear the interface reference and that `SetConfiguration` releases interfaces on the blocking thread using `ReleaseSoon`.
How it was found
- Obtain WebUSB access to a device (either via existing permission or a malicious device).
- Using a compromised renderer, send a Mojo IPC to claim an interface.
- Send `SetInterfaceAlternateSetting` followed immediately by `SetConfiguration` to trigger the race.
- During the race window, perform a heap spray via other IPCs or WebUSB operations to overwrite the freed system malloc chunk with attacker-controlled data.
- The virtual call in `GetNumEndpoints` dereferences the attacker-controlled vtable, resulting in arbitrary code execution (RCE) in the browser process.
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.
WebUSB lets websites talk to USB devices. A bug in how the browser handles certain USB commands on macOS can cause it to use memory after it has been freed. If an attacker controls a malicious website, they might exploit this to run harmful code on the computer.
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.