Skip to content
Memory corruption Advisory Advanced CVE-2026-12011

Use after free WebMIDI (CVE-2026-12011)

A use-after-free exists in Chrome's Windows MIDI implementation because TaskService::PostBoundTask stamps tasks with the current bound instance ID rather than the ID active when the callback was registered. An attacker with a compromised renderer could trigger rapid MIDI session re-binding so a stale WinRT callback runs against a freed MidiPortManager, potentially causing heap corruption in the browser process.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 13 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 Chrome's Windows-specific MIDI implementation, MidiManagerWinrt, during rapid session re-binding. Stale WinRT callbacks can capture and run under a newly bound instance ID, defeating the TaskService validation gate and calling methods on a freed MidiPortManager. This could lead to potential heap corruption in the browser process.

Affected files:

  • media/midi/midi_manager_winrt.cc
  • media/midi/task_service.cc

Estimated timestamp from git blame: 2018-01-17

Root Cause Analysis

In media/midi/task_service.cc, TaskService::PostBoundTask() stamps posted tasks with the current bound_instance_id_ instead of the ID that was active when the caller's callback was registered:

C++
void TaskService::PostBoundTask(RunnerId runner_id, base::OnceClosure task) {
  InstanceId instance_id;
  {
    base::AutoLock lock(lock_);
    if (bound_instance_id_ == kInvalidInstanceId)
      return;
    instance_id = bound_instance_id_;
  }
  GetTaskRunner(runner_id)->PostTask(
      FROM_HERE, base::BindOnce(&TaskService::RunTask, base::Unretained(this),
                                instance_id, runner_id, std::move(task)));
}

MidiManagerWinrt registers WinRT callbacks that execute on WinRT-owned thread pool threads outside of Chrome's immediate control. These callbacks capture a raw MidiPortManager* pointer and call PostBoundTask() directly when events (such as device addition/removal or message receipt) occur:

C++
MidiPortManager* port_manager = this;
TaskService* task_service = midi_service_->task_service();
hr = watcher_->add_Added(
    WRL::Callback<...>
        [port_manager, task_service](IDeviceWatcher*, IDeviceInformation* info) {
          task_service->PostBoundTask(
              kComTaskRunner, base::BindOnce(&MidiPortManager::OnAdded,
                                             base::Unretained(port_manager),
                                             dev_id, dev_name));
          return S_OK;
        }).Get(), &token_Added_);

These callbacks are torn down in StopWatcher(), which is called inside FinalizeOnComRunner (a static task posted by the destructor on kComTaskRunner after UnbindInstance() completes).

If a new MIDI session is initiated before the deferred cleanup task FinalizeOnComRunner executes on kComTaskRunner, a new MidiManagerWinrt instance binds to the TaskService, setting bound_instance_id_ to a new ID.

If a stale WinRT callback from the first session fires before FinalizeOnComRunner runs, it calls PostBoundTask(). This call reads the newly bound instance ID, stamping the task with the active ID and successfully posting it to kComTaskRunner.

Because FinalizeOnComRunner is queued before this stale task, it executes first, unregistering the watcher and deleting the old MidiPortManager instance. When the stale task subsequently runs, it bypasses the IsInstanceIdStillBound check (since the active instance ID matches) and dereferences the freed MidiPortManager pointer via base::Unretained, causing a Use-After-Free (UAF).

Potential Steps to Reproduce

Note: The following steps are potential/suggested vectors of exploitation. Our security analysis tooling does not currently have the capability to execute live code or verify this via a working proof-of-concept.

  1. From a compromised renderer process, request a MIDI session using the Mojo interface midi::mojom::MidiSessionProvider. This constructs MidiManagerWinrt (Instance #1) and registers the WinRT callbacks.
  2. Rapidly terminate the session (e.g., by closing the Mojo pipe). This invokes the destructor, which calls UnbindInstance() and queues the cleanup task FinalizeOnComRunner on kComTaskRunner to stop the watchers and delete the port managers.
  3. Immediately initiate a new MIDI session. This constructs a second MidiManagerWinrt (Instance #2), which binds to TaskService and sets bound_instance_id_ to a new valid ID.
  4. If a stale WinRT callback from Instance #1 fires before FinalizeOnComRunner has executed on kComTaskRunner, it calls PostBoundTask(). This stamps the task with the ID of Instance #2 and posts it to the queue.
  5. On the kComTaskRunner thread:
    • FinalizeOnComRunner runs first, deleting the port managers of Instance #1.
    • The stale callback task runs next, bypassing validation because its stamped ID matches the active Instance #2 ID, and dereferences the deleted port manager of Instance #1.

Impact and Severity

This issue allows for a potential Use-After-Free (UAF) on a heap-allocated MidiInPortManager or MidiOutPortManager in the browser process (which is unsandboxed). An attacker with control over a compromised renderer could potentially leverage this heap corruption to escape the sandbox and achieve Remote Code Execution (RCE) with the privileges of the browser process. Because this is a high-severity browser-process memory corruption issue, it is classified as Severity 0 (Critical).

Suggested Fix

To resolve this issue, TaskService::PostBoundTask (and delayed tasks) should not rely on reading a dynamically changing global bound_instance_id_ at the time of posting. Instead, classes posting bound tasks should track and supply their own bound instance ID associated with their specific registration lifetime, or MidiPortManager should use weak pointers or ref-counted callbacks to ensure that tasks cannot execute on a freed instance. Alternatively, ensuring that WinRT watchers are stopped synchronously on the calling sequence during unbinding would prevent stale callbacks from firing altogether.

Evaluated with Chrome root at commit: fb72408a8493c46bc75fae1c70d03daec96b3040


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 TaskService::PostBoundTask reads the current global bound_instance_id_ at posting time instead of the instance ID that was active when the callback was registered, so stale callbacks are stamped with a new valid ID and pass validation.

Impact

An attacker with control over a compromised renderer could potentially leverage the heap corruption to escape the sandbox and achieve remote code execution with the browser process's privileges.

What the attacker needed

Compromised renderer process; Windows platform; rapid MIDI session re-binding; stale WinRT callback fires at the right time

The fix

The report suggests that PostBoundTask should use the instance ID associated with the caller's registration lifetime, or that MidiPortManager should use weak pointers or ref-counted callbacks, or that WinRT watchers should be stopped synchronously during unbinding.

How it was found

  1. From a compromised renderer, request a MIDI session through the Mojo interface, creating the first MidiManagerWinrt instance and registering WinRT callbacks.
  2. Rapidly terminate the session, which queues FinalizeOnComRunner to stop watchers and delete port managers.
  3. Immediately start a new MIDI session, creating a second instance that binds to TaskService with a new instance ID.
  4. A stale WinRT callback from the first session fires and calls PostBoundTask, which stamps the task with the new instance ID.
  5. On the COM task runner, FinalizeOnComRunner runs first and deletes the old port managers, then the stale task runs, passes validation, and dereferences the freed 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 memory but keeps a pointer to it, later using that pointer is called a use-after-free. Here, a background callback from an old MIDI session can fire after its data has been deleted, and because the code checks the wrong session identifier it does not notice. The result is that the browser process may read or write memory it no longer owns, which can crash it or let an attacker run 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.