Use after free in WebRTC (CVE-2026-9111)
A shared pointer to a mouse cursor object in the Linux/Wayland screen capture code is read and written by two threads without a lock, so a race can hand a freed object to the frame composer. An attacker could then leak browser-process heap memory into the captured video, and a double-free gives a possible path to code execution in the unsandboxed browser process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 30 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 without the Chrome Security team. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A data race on the std::unique_ptr<MouseCursor> mouse_cursor_ member in SharedScreenCastStreamPrivate can occur between the PipeWire thread and the capture thread. This lack of synchronization allows a dangling pointer to be moved to the composer, leading to a potential Use-After-Free read (information leak) and Double-Free in the unsandboxed browser process.
Affected files:
third_party/webrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.ccthird_party/webrtc/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.ccthird_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc
Estimated timestamp from git blame: 2024-06-27
Root Cause
A thread safety issue exists in SharedScreenCastStreamPrivate within the WebRTC desktop capture module for Linux/Wayland (third_party/webrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc). The member mouse_cursor_ (a std::unique_ptr<MouseCursor>) is accessed and modified without synchronization from two different threads:
- Writer (PipeWire thread): The background
pipewire-main-loopthread invokesProcessBuffer(), which creates a newMouseCursorobject and assigns it tomouse_cursor_(line 777). This assignment is performed without holding any mutex. - Reader (Capture thread): The
desktopCaptureThread(an unsandboxed thread in the browser process) callsCaptureCursor(), which executesreturn std::move(mouse_cursor_);(line 702). This is also performed without synchronization.
Vulnerability Details
Because std::unique_ptr assignment and move operations are not atomic, concurrent execution leads to a data race on the internal raw pointer.
- The Reader thread executes
std::move(mouse_cursor_)and reads the raw pointer just before the Writer thread completes its assignment of a new cursor. - The Writer thread completes its assignment, which triggers the deletion of the old
MouseCursorobject. - The Reader thread completes its move, successfully constructing a new
unique_ptrthat wraps the now-freed pointer.
This leads to two distinct impacts:
- Use-After-Free (Information Leak): The dangling pointer is passed to
DesktopAndCursorComposer::OnMouseCursor(). During frame composition,DesktopFrameWithCursorcallsAlphaBlend, which reads from the freedMouseCursor's image data and copies it into the captured video frame. This blends browser-process heap memory into the video stream sent back to the web page. - Double-Free (Potential RCE): The
DesktopAndCursorComposerstores the dangling pointer in its ownstd::unique_ptr<MouseCursor> cursor_. When a new cursor is received, or upon destruction,cursor_.reset()is called, which attempts todeletethe already-freed pointer a second time. BecauseMouseCursormanages aDesktopFramewith a virtual destructor, this provides a primitive for control-flow hijacking in the unsandboxed browser process.
Potential Attack Steps
(Note: These are suggested steps based on code analysis; a working PoC has not been executed.)
- An attacker tricks a victim on Linux (Wayland/PipeWire) into visiting a malicious site.
- The site calls
navigator.mediaDevices.getDisplayMedia({ video: true }). - Once the user grants permission, the browser process begins capturing the screen using the vulnerable Wayland module.
- The malicious page rapidly alters CSS cursor shapes or prompts the user to move the mouse rapidly while capturing frames at a high rate. This maximizes the execution frequency of both threads to win the race condition.
Suggested Fix
Access to mouse_cursor_ and mouse_cursor_position_ must be synchronized. Since queue_lock_ and latest_frame_lock_ already exist in SharedScreenCastStreamPrivate, one of these mutexes (or a new dedicated mutex) should be held during both the assignment in ProcessBuffer() and the read/move in CaptureCursor() and CaptureCursorPosition().
Evaluated with Chrome root at commit: 7353d249d9cacf9c7218e1d7b8a39cf39c72d646
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. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 mouse_cursor_ unique_ptr is assigned on the PipeWire thread and moved from on the capture thread with no mutex protecting either access.
Impact
Heap memory from the browser process could be blended into the video sent to the page, and the double-free may allow control-flow hijacking in the unsandboxed browser process; the report notes no working proof of concept was executed.
What the attacker needed
Linux with Wayland/PipeWire; victim visits a malicious page; user grants screen-capture permission; race must be won
The fix
Access to the cursor pointer and position should be synchronised, for example by holding an existing mutex or a new dedicated one during both the write and the read.
How it was found
- Trick a victim on Linux with Wayland/PipeWire into visiting a malicious site.
- The site requests display capture through the browser's screen-sharing API.
- The user grants permission and the browser starts capturing via the vulnerable Wayland module.
- The page rapidly changes cursor shapes or has the user move the mouse quickly while frames are captured at a high rate, to win the race.
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 an object, any leftover pointer to it becomes invalid; using it anyway is called a use-after-free. Here two threads touch the same pointer at the same time without a lock, so one can grab the pointer just as the other frees the object behind it. The result is that stale memory can be read into the screen recording, and the same object may be freed twice.
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.