Use after free in WebMIDI (CVE-2026-10014)
Access to the MIDI output port vector in MidiManagerAndroid was not synchronised between the Android UI thread and the Chrome IO thread, so a device attach could reallocate the vector while the IO thread was reading it. This could cause a use-after-free of the vector's backing store, which the report suggests might be escalated to JNI type confusion in the browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 9 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 race condition in MidiManagerAndroid allows for a potential Use-After-Free (UAF) on a vector's backing store due to unsynchronized access between the Android UI and Chrome IO threads. This vulnerability could be leveraged to achieve JNI type confusion within the browser process. The issue stems from mutating MIDI port vectors during device attachment while concurrently reading them to dispatch MIDI data.
Affected files:
media/midi/midi_manager_android.ccmedia/midi/midi_manager_android.h
Estimated timestamp from git blame: Unknown (Google3 checkout)
Summary
A potential race condition exists in MidiManagerAndroid because access to the all_output_ports_ vector is not synchronized between the Android UI thread and the Chrome IO thread. This can result in a Use-After-Free (UAF) during vector reallocation, which may lead to JNI type confusion in the unsandboxed browser process.
Technical Details
MidiManagerAndroid manages MIDI output ports using a std::vector<raw_ptr<MidiOutputPortAndroid>> all_output_ports_. While the class defines a base::Lock lock_, this lock is not acquired during many critical operations on the port vectors.
1. Mutation on the UI Thread:
When a MIDI device is attached, the Android framework triggers JNI callbacks on the UI thread. This eventually calls MidiManagerAndroid::OnAttached (in media/midi/midi_manager_android.cc), which invokes AddDevice. Inside AddDevice, the code performs all_output_ports_.push_back(port.get()) without any locking.
2. Concurrent Read on the IO Thread:
Renderer-initiated MIDI data transfers (via Mojo SendData) are handled by MidiHost on the IO thread. This calls MidiManagerAndroid::DispatchSendMidiData, which reads from the vector using all_output_ports_[port_index] to retrieve a port pointer, also without holding a lock.
3. The Race and UAF:
If the push_back on the UI thread triggers a vector reallocation, the vector's internal backing storage is deallocated and replaced. If the IO thread is concurrently reading from the vector, it may access the old storage after it has been freed.
Notably, while the elements are raw_ptr, MiraclePtr (BackupRefPtr) protects the objects the pointers point to, but not the internal backing array of the std::vector itself. Thus, the UAF occurs on the buffer containing the pointers.
Potential Exploitation Primitive
An attacker could potentially escalate this UAF to JNI type confusion:
- Pointer Capture: The IO thread reads a garbage value from the freed vector storage and binds it as a
base::Unretainedpointer into a delayed task. - Heap Reclamation: By providing a
timestampin the Mojo call, the renderer can delay the task's execution, creating a window to spray the browser process heap and reclaim the freed storage with controlled data. - JNI Type Confusion: When the task executes, it calls
MidiOutputPortAndroid::Sendon the controlled pointer. This method reads ajobjecthandle from offset 0 (the location ofScopedJavaGlobalRef<jobject> raw_port_) and passes it toJava_MidiOutputPortAndroid_send. This allows the attacker to invoke JNI methods using an arbitrary object handle.
Suggested Potential Steps to Trigger
Note: These steps are theoretical as our tooling cannot currently execute code.
- A compromised renderer process obtains MIDI permissions.
- The renderer begins a high-frequency stream of MIDI data to an existing port.
- Simultaneously, an external event (such as a malicious App cycling virtual MIDI devices on the same Android device) triggers frequent MIDI device-attach notifications.
- The resulting race triggers a vector reallocation in
AddDevicewhileDispatchSendMidiDatais active. - The attacker attempts to groom the browser heap to control the contents of the freed vector buffer during the reallocation window.
Suggested Fix
Ensure that all accesses (reads and writes) to all_input_ports_, all_output_ports_, and their associated index maps in MidiManagerAndroid are protected by a base::Lock. The existing lock_ in the class should be utilized for this purpose.
Evaluated with Chrome root at commit: 29093e11cf509e3593f6229e4b1b075cca356049
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 class's existing lock was not taken around reads and writes of the port vectors, so a push_back reallocation on the UI thread could free storage the IO thread was still reading.
Impact
The report claims this could potentially lead to JNI type confusion in the unsandboxed browser process, but the steps are theoretical and the tooling could not execute code to confirm it.
What the attacker needed
Compromised renderer; MIDI permissions granted; attacker can cycle virtual MIDI devices
The fix
All reads and writes of the port vectors and their index maps should be protected by the class's existing lock.
How it was found
- A compromised renderer obtains MIDI permissions.
- The renderer streams MIDI data to an existing port at high frequency.
- At the same time, frequent MIDI device-attach events are triggered on the Android device.
- The race causes a vector reallocation in AddDevice while DispatchSendMidiData is reading the vector.
- The attacker tries to groom the browser heap to control the freed vector buffer.
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 program keeps a list of MIDI devices in memory. One part of the browser adds a device to the list while another part reads it at the same time, and adding can move the list to a new memory location, leaving the reader looking at freed memory. Reading freed memory can crash the browser or, in theory, let an attacker influence what is read.
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.