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.
- Fix shipped in 34 days
Steps to reproduce the problem
- patch the sleep patch.
- run the poc.html and share.
- stop share then uaf
Problem Description
- As with the issue I reported earlier, there is a block function in
ResetStreamTo, andcomplexHandlerwill execute tasks completely asynchronously for Macos. Therefore, if theScreenCaptureKitDeviceMacclass is destroyed while this block function is running, it will cause UAF.
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).");
}
}];
}
-
When you click to stop screen sharing ,it will call StopAndReleaseDeviceOnDeviceThread,then it will release ScreenCaptureKitDeviceMac ,see asan.log
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
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
- Patch the sleep call in the build.
- Run the proof-of-concept page and start sharing.
- 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.