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

Use after free in CameraCapture (CVE-2026-15899)

A callback member in the Apple video capture code is read and written from two threads without a lock, so a photo completion on an AVFoundation background thread can race with a new photo request on the device thread. This could free the callback's internal state while it is still in use, leading to a use-after-free or double free that may allow sandbox escape and code execution.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 51 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: An unsynchronized cross-thread data race exists in VideoCaptureDeviceApple on macOS and iOS, where photo_callback_ is accessed concurrently without mutual exclusion. The device thread reads and writes the callback in TakePhoto() while an AVFoundation background thread concurrently runs or resets it in OnPhotoTaken() or OnPhotoError(). This race can potentially lead to a Use-After-Free (UAF) or Double Free of the callback's underlying BindState.

Affected files:

  • media/capture/video/apple/video_capture_device_apple.mm
  • media/capture/video/apple/video_capture_device_apple.h
  • media/capture/video/apple/video_capture_device_avfoundation.mm

Estimated timestamp from git blame: 2016-07-15

Summary

An unsynchronized cross-thread data race in VideoCaptureDeviceApple on macOS and iOS can potentially lead to a Use-After-Free (UAF) and Double Free of a callback's underlying BindState. This vulnerability is reachable by a compromised renderer or a site with camera permissions spamming Mojo IPCs for image capture.

Root Cause Analysis

In VideoCaptureDeviceApple, the in-flight image capture callback is stored in the member variable photo_callback_, which is a base::OnceCallback<void(mojom::BlobPtr)> (aliased as TakePhotoCallback):

  • File Reference: media/capture/video/apple/video_capture_device_apple.h, line 132:

    C++
    TakePhotoCallback photo_callback_;
    

This member is accessed and modified across different threads without any lock protection or synchronization:

  1. Device Thread (task_runner_): In VideoCaptureDeviceApple::TakePhoto, the callback is read and assigned on the device thread:

    • File Reference: media/capture/video/apple/video_capture_device_apple.mm, lines 129–139:
      C++
      void VideoCaptureDeviceApple::TakePhoto(TakePhotoCallback callback) {
        DCHECK(task_runner_->BelongsToCurrentThread());
        DCHECK(state_ == kCapturing) << state_;
      
        if (photo_callback_) {
          return;
        }
        photo_callback_ = std::move(callback);
        [capture_device_ takePhoto];
      }
      
  2. AVFoundation Delegate Thread: When a photo is successfully processed or encounters an error, the AVFoundation delegate thread (an arbitrary background thread / dispatch queue) directly invokes OnPhotoTaken() or OnPhotoError() on the receiver. Unlike other receiver methods like ReceiveError which use task_runner_->PostTask to safely hop back to the device thread, these methods execute directly on the delegate's thread:

    • File Reference: media/capture/video/apple/video_capture_device_apple.mm, lines 264–282:
      C++
      void VideoCaptureDeviceApple::OnPhotoTaken(const uint8_t* image_data,
                                                 size_t image_length,
                                                 const std::string& mime_type) {
        DCHECK(photo_callback_);
        ...
        std::move(photo_callback_).Run(std::move(blob));
      }
      
      void VideoCaptureDeviceApple::OnPhotoError() {
        VLOG(1) << __func__ << " error taking picture";
        photo_callback_.Reset();
      }
      

Potential Concurrency / Exploitation Mechanism

Because OnceCallback relies on a non-atomic reference-counted BindState object (scoped_refptr<BindStateBase>), concurrent non-atomic accesses on two threads can lead to memory corruption:

  1. Thread B (AVFoundation background thread) executes OnPhotoTaken() and performs std::move(photo_callback_).Run(...). During the move, it reads the address of the underlying BindState (BindState_A) into a CPU register.
  2. Thread A (Device thread) concurrently processes a new TakePhoto() request. It reads photo_callback_ before Thread B has written nullptr to clear it. Thread A then executes photo_callback_ = std::move(callback), which overwrites the slot with a new callback and calls Release() on the old BindState_A.
  3. Since the reference count of BindState_A drops to 0, the memory allocated for BindState_A is freed.
  4. Thread B completes its move operation and writes nullptr to photo_callback_ (corrupting Thread A's newly assigned callback), and then invokes the callback using the pointer in its register, which now points to the freed BindState_A object. This results in a Use-After-Free (UAF).

Potential Trigger Steps

Note: These are potential steps as our tooling does not have the ability to run code or verify a live exploit.

  1. A web page with camera permissions (or a compromised Renderer process) initiates connection to the media.mojom.ImageCapture Mojo interface.
  2. The Renderer spams the media.mojom.ImageCapture.TakePhoto Mojo IPC in a tight loop without waiting for the returned promises to resolve.
  3. If timed correctly, the concurrent execution of a new TakePhoto call on the Device Thread and the completion callback on the AVFoundation thread results in the data race, causing a heap corruption crash or potential control flow hijacking.

Impact

  • On macOS, the Video Capture Service runs as kNoSandbox (unsandboxed utility process).
  • On iOS, the service runs inside the browser process.
  • Exploiting this UAF could potentially allow an attacker to escape the renderer sandbox and execute arbitrary code with full user or browser privileges.

Suggested Fix

Ensure that all callback access on the VideoCaptureDeviceApple instance occurs exclusively on the designated task_runner_ thread. The methods OnPhotoTaken and OnPhotoError must marshal execution back to the device thread using task_runner_->PostTask, rather than executing the callback directly on the AVFoundation background thread. For example:

C++
void VideoCaptureDeviceApple::OnPhotoTaken(const uint8_t* image_data,
                                           size_t image_length,
                                           const std::string& mime_type) {
  // Create a copy of the image data to safely pass across threads
  std::vector<uint8_t> data(image_data, image_data + image_length);
  task_runner_->PostTask(
      FROM_HERE,
      base::BindOnce(&VideoCaptureDeviceApple::OnPhotoTakenOnDeviceThread,
                     weak_factory_.GetWeakPtr(), std::move(data), mime_type));
}

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.

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

The photo callback member is accessed and modified from both the device thread and an AVFoundation delegate thread without any synchronisation, and the delegate methods do not hop back to the device thread as other receiver methods do.

Impact

Exploiting the use-after-free could potentially let an attacker escape the renderer sandbox and run arbitrary code with full user or browser privileges, since the capture service is unsandboxed on macOS and runs in the browser process on iOS.

What the attacker needed

Camera permission or compromised renderer; precise timing of two threads

The fix

All callback access should happen only on the designated device thread, with the photo completion and error handlers posting back to it instead of running on the AVFoundation thread.

How it was found

  1. A page with camera permission, or a compromised renderer, connects to the image capture Mojo interface.
  2. The renderer sends TakePhoto requests in a tight loop without waiting for the results.
  3. A new TakePhoto on the device thread races with the completion callback on the AVFoundation thread, corrupting the heap.

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 can ask the camera to take a picture and hand over a small function to run when the picture is ready. Here two different threads (independent streams of execution inside the same program) touch that stored function at the same time without coordinating. One thread can free the memory behind it while the other is still using it, which can crash the program or let an attacker 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.