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

Use after free in FileSystem (CVE-2026-8512)

A use-after-free flaw exists in the macOS File System Access API's directory watcher because the Cancel method lacks a synchronisation barrier, allowing the watcher object to be freed while an OS callback still holds a raw pointer to it. An attacker could potentially exploit this race condition to achieve arbitrary code execution in the browser process.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 50 days

Project Fortify, an experimental security project, has identified the following potential security issue.

Overview: A Use-After-Free (UAF) vulnerability exists in the macOS implementation of the File System Access API's directory watcher. The FilePathWatcherFSEvents::Cancel method lacks a synchronization barrier, allowing the object to be destroyed on a ThreadPool sequence while an OS callback concurrently accesses its raw pointer on a libdispatch thread. This can potentially lead to arbitrary code execution in the highly-privileged browser process.

Affected files:

  • content/browser/file_system_access/file_path_watcher/file_path_watcher_fsevents.cc
  • content/browser/file_system_access/file_path_watcher/file_path_watcher_fsevents.h

Estimated timestamp from git blame: 2024-09-20

Background

In 2024, Chromium forked base/files/file_path_watcher_fsevents.cc into content/browser/file_system_access/file_path_watcher/file_path_watcher_fsevents.cc to support the File System Access API's observation features on macOS. This implementation utilizes the macOS FSEvents.framework to monitor file system changes.

To receive callbacks from the OS, FSEventStreamCreate is called with a context structure (FSEventStreamContext) where the info field is set to the raw this pointer of the FilePathWatcherFSEvents object. The OS then invokes a static FSEventsCallback on a serial libdispatch worker thread (queue_), passing back the raw pointer.

Vulnerability Details

The original implementation in base/ utilized a dispatch_sync barrier inside its Cancel() method to ensure thread safety during object teardown. This call blocked the calling thread until any currently executing blocks on the libdispatch queue completed, guaranteeing the watcher object still existed when the OS callback was running.

In the content/ fork, this dispatch_sync wrapper was removed from Cancel(). Consequently, DestroyEventStream() is called directly on the Chromium ThreadPool sequence. While FSEventStreamStop and FSEventStreamInvalidate prevent future callbacks from being scheduled, they do not block or abort an already running callback on the libdispatch thread.

This introduces a critical race condition:

  1. The OS schedules FSEventsCallback on the libdispatch thread, which begins processing a batch of file system events in a for loop.
  2. Concurrently, the watcher is cancelled (e.g., due to the webpage navigating away or calling disconnect()). Cancel() runs on the ThreadPool, stops the stream, and returns.
  3. The FilePathWatcherFSEvents object is immediately destroyed and its memory freed back to PartitionAlloc.
  4. The FSEventsCallback on the libdispatch thread finishes its loop and attempts to use the now-freed watcher pointer: watcher->task_runner()->PostTask(...).

Exploitation and Impact

Because the dangling this pointer is held by the macOS framework as a raw C void* in the FSEventStreamContext, it is entirely unmitigated by MiraclePtr (BackupRefPtr).

An attacker can reliably widen the race window by triggering a massive number of file system events (e.g., rapidly creating/deleting files via FileSystemWritableFileStream). This causes the for (size_t i = 0; i < num_events; i++) loop in the FSEventsCallback to run for a long time, giving the attacker ample opportunity to trigger destruction and reclaim the freed memory using standard heap grooming techniques.

When the reclaimed memory is groomed with attacker-controlled data, the dereference of watcher->task_runner() returns a fake scoped_refptr<base::SequencedTaskRunner>. When PostTask() is called, it triggers a virtual method dispatch (PostDelayedTask) using an attacker-controlled vtable pointer. This leads to arbitrary Remote Code Execution (RCE) in the browser process, resulting in a full Sandbox Escape.

Potential Reproduction Steps

Note: These are suggested steps to trigger the vulnerability, as our setup does not yet have the ability to run or verify arbitrary code/exploits.

  1. Host a malicious webpage that requests directory access via window.showDirectoryPicker(). Persuade the user to select a local directory.
  2. In JavaScript, initialize a FileSystemObserver on the granted directory handle: observer.observe(dirHandle, {recursive: true}).
  3. Use FileSystemWritableFileStream or similar APIs to generate a massive volume of file system events (e.g., thousands of rapid creates and deletes) in the observed directory. This keeps the FSEventsCallback on the libdispatch thread busy.
  4. While the background file operations are ongoing, trigger the destruction of the watcher. This can be done by calling observer.disconnect() or by navigating the page (window.location = '...').
  5. (Exploitation phase) Concurrently, perform heap grooming via Web APIs (like allocating carefully sized Blobs) to reclaim the freed FilePathWatcherFSEvents memory chunk in the browser process.
  6. The browser process will crash or jump to an attacker-controlled address when the libdispatch thread attempts to call watcher->task_runner()->PostTask(...).

Evaluated with Chrome root at commit: False


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. Please feel free to reach out to me if you have concerns or feedback.

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 the removal of a dispatch_sync barrier in the Cancel method means the watcher object can be destroyed while an already-running FSEvents callback still holds a raw pointer to it.

Impact

An attacker could potentially achieve arbitrary code execution in the highly-privileged browser process, leading to a full sandbox escape, though the report notes the reproduction steps are suggested and not yet verified.

What the attacker needed

MacOS with File System Access API; victim grants directory access; attacker can trigger many file events; race condition must be won

The fix

The Cancel method should be fixed by restoring a synchronisation barrier (such as dispatch_sync) to ensure any running callback completes before the watcher object is destroyed.

How it was found

  1. Host a malicious webpage that requests directory access via window.showDirectoryPicker() and persuade the user to select a local directory.
  2. In JavaScript, initialise a FileSystemObserver on the granted directory handle with recursive observation.
  3. Generate a massive volume of file system events (e.g., thousands of rapid creates and deletes) in the observed directory to keep the FSEventsCallback busy.
  4. While background file operations are ongoing, trigger destruction of the watcher by calling observer.disconnect() or navigating the page.
  5. Concurrently perform heap grooming via Web APIs to reclaim the freed FilePathWatcherFSEvents memory chunk.
  6. The browser process will crash or jump to an attacker-controlled address when the libdispatch thread attempts to call watcher->task_runner()->PostTask(...).

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 frees memory but keeps using a pointer to it, like deleting a file but still trying to open it. Here, a file-watching feature on macOS can free its internal object while the operating system is still calling back into it, so the callback touches memory that may now belong to something else. If an attacker can control what fills that freed memory, they might redirect the program to 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.

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.