Skip to content
Memory corruption Advisory Advanced CVE-2024-6774

Use after free in Screen Capture (CVE-2024-6774)

A use-after-free occurs in Chromium's macOS screen capture code when the ScreenCaptureKitDeviceMac object is destroyed while an asynchronous completion handler from ResetStreamTo is still pending. An attacker could potentially trigger a crash or memory corruption by manipulating screen sharing start and stop actions.

lime Follow

Originally disclosed on Chrome VRP

Bounty$6,000 High View original
  • Fix shipped in 34 days

Steps to reproduce the problem

  1. patch the sleep patch.
  2. run the poc.html and share.
  3. stop share then uaf

Problem Description

  1. As with the issue I reported earlier, there is a block function in ResetStreamTo, and complexHandler will execute tasks completely asynchronously for Macos. Therefore, if the ScreenCaptureKitDeviceMac class is destroyed while this block function is running, it will cause UAF.
C++
 void ResetStreamTo(SCWindow* window) override {
   DCHECK(device_task_runner_->RunsTasksInCurrentSequence());

   if (!window || is_resetting_) {
     client()->OnError(
         media::VideoCaptureError::kScreenCaptureKitResetStreamError,
         FROM_HERE, "Error on ResetStreamTo.");
     return;
   }

   is_resetting_ = true;
   SCContentFilter* filter =
       [[SCContentFilter alloc] initWithDesktopIndependentWindow:window];

   [stream_ updateContentFilter:filter
              completionHandler:^(NSError* _Nullable error) { 
                is_resetting_ = false;    ///uaf
                if (error) {
                  client()->OnError(
                      media::VideoCaptureError::kScreenCaptureKitStreamError,
                      FROM_HERE,
                      "Error on updateContentFilter (fullscreen window).");
                }
              }];
 }
  1. When you click to stop screen sharing ,it will call StopAndReleaseDeviceOnDeviceThread,then it will release ScreenCaptureKitDeviceMac ,see asan.log

  2. https://source.chromium.org/chromium/chromium/src/+/main:content/browser/media/capture/screen_capture_kit_device_mac.mm;l=428?q=screen_capture_kit_device_mac.mm&ss=chromium%2Fchromium%2Fsrc

  3. https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/in_process_launched_video_capture_device.cc;l=29?q=StopAndReleaseDeviceOnDeviceThread&ss=chromium%2Fchromium%2Fsrc

bitset: https://source.chromium.org/chromium/chromium/src/+/f6eb52423e79e4ebd07a93da248c4c4a3d79f22e

fix : will be update soon.

patch to sleep : will be update soon.

notice : it not protected by miracle.

!!! i will reduce my poc and update it soon. if you are confirm it, please fix it asap.!!!

Summary

AddressSanitizer: heap-use-after-free on ScreenCaptureKitDeviceMac::ResetStreamTo

Custom Questions

Type of crash:

browser

Crash state:

see asan.log

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A

The original report as published on the Chromium issue tracker, by lime(@limeSec_) and fmyy(@binary_fmyy) From TIANGONG Team of Legendsec at QI-ANXIN Group. 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

Impact

Could cause a browser crash and potentially memory corruption, though the report does not demonstrate code execution.

What the attacker needed

MacOS; user starts and stops screen sharing; crafted page or timing

The fix

The report says a fix will be provided soon but does not describe one; the handler should hold a weak reference or the object should outlive the asynchronous callback.

How it was found

  1. Patch the sleep call in the build.
  2. Run the proof-of-concept page and start sharing.
  3. Stop sharing to trigger the use-after-free.

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 you share your screen, the browser asks the operating system to capture it. A small piece of code runs later to finish the setup, but if you stop sharing before that code runs, the browser has already thrown away the object it needs. That leaves the late code writing to freed memory, which is called a use-after-free and can crash the browser 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 by lime

View all

4 more disclosed reports, best first.

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.