Use after free in WebRTC (CVE-2023-7010)
A dangling pointer in WebRTC's PacketRouter arises when an SDP SIM group SSRC collides with an existing SSRC from another track, leaving a stale entry in send_modules_list_. An attacker could trigger a use-after-free by setting a new local offer, potentially causing a renderer crash.
Originally disclosed on Chrome VRP
- Fix shipped in 14 days
VULNERABILITY DETAILS
Summary
A dangling pointer vulnerability is present in WebRTC's PacketRouter due to an SDP SIM group SSRC from one track (e.g., video) colliding with an existing SSRC from a different track (e.g., audio). This inconsistency between the send_modules_map_ and the send_modules_list_ can lead to a use after free.
Technical Description
The PacketRouter class maintains a map (send_modules_map_) for tracking SSRC to rtp_module associations. When an SDP SIM group contains an SSRC that collides with an existing SSRC from another track, the existing entry in the map is overwritten, but a dangling entry remains in send_modules_list_. This dangling entry becomes an issue when setting a new local offer on the connection, leading to a use after free.
Steps to Reproduce
- Munge the initial offer SDP to contain a SIM group with an SSRC that collides with an existing SSRC from a different track.
- Set this SDP as the local content, causing two
rtp_modules with the same SSRC to be written tosend_modules_map_, leading one entry to be overwritten. - Attempt to remove the mapping for the colliding SSRC, which results in a dangling entry in
send_modules_list_. - Set a new local offer without ending the call, triggering a use after free when packets are sent using
send_modules_list_.
Suggested Fix
-
**Conditional Entry in List**: Only add to
send_modules_list_if the SSRC is not already insend_modules_map_. Easier to apply but doesn't resolve the fragile design of map/list synchronization. -
**Direct Map Iteration**: Eliminate
send_modules_list_and iterate oversend_modules_map_. Simplifies code but requires logic to prioritize video during iteration. -
**Map with Custom Comparator**: Use a single map with a custom comparator to sort
RtpRtcpInterfacepointers. Simplifies code and naturally prioritizes video, but the custom comparator could add complexity. The RTP module pointers would have to become the keys with SSRCs as values, which doesn't seem ergonomic either. -
**Defense-in-Depth: Parser-Level Checks**: Add checks to validate SIM group SSRCs to prevent collisions with existing SSRCs. Adds an extra layer of protection but doesn't address the core issue.
I'd recommend something along the lines of (1-3) along with (4).
VERSION
Chrome Version: 118.0.5966.0 Canary
Operating System: All
REPRODUCTION CASE
See attached repro.html
FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION
Type of crash: Tab (renderer)
Crash State: See attached asan.log
CREDIT INFORMATION
Reporter credit: Ned Williamson of Google Project Zero
This bug is subject to a 90-day disclosure deadline. If a fix for this
issue is made available to users before the end of the 90-day deadline,
this bug report will become public 30 days after the fix was made
available. Otherwise, this bug report will become public at the deadline.
The scheduled deadline is 2023-11-27.
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 PacketRouter maintains two unsynchronised data structures (a map and a list) for SSRC-to-module mappings, and a collision overwrites the map entry but leaves a dangling pointer in the list.
Impact
The use-after-free could crash the renderer tab, and may potentially lead to code execution, though the report only demonstrates a crash.
What the attacker needed
Victim visits a malicious page; browser supports WebRTC
The fix
The report suggests several fixes: only add to send_modules_list_ if the SSRC is not already in send_modules_map_, eliminate send_modules_list_ and iterate over send_modules_map_, or use a single map with a custom comparator, plus parser-level checks to validate SIM group SSRCs.
How it was found
- Munge the initial offer SDP to contain a SIM group with an SSRC that collides with an existing SSRC from a different track.
- Set this SDP as the local content, causing two rtp_modules with the same SSRC to be written to send_modules_map_, leading one entry to be overwritten.
- Attempt to remove the mapping for the colliding SSRC, which results in a dangling entry in send_modules_list_.
- Set a new local offer without ending the call, triggering a use after free when packets are sent using send_modules_list_.
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.
WebRTC is a technology for real-time audio and video in browsers. A use-after-free happens when a program keeps using memory after it has been freed, which can crash the program or let an attacker run code. Here, a mismatch in how two lists track media streams causes the program to use freed memory.
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.