parent UAF in AudioIPC ServerStreams data_callback from bad content process data
A use-after-free exists in the AudioIPC server: when a StreamDestroy message removes a ServerStream from the streams map, a later data_callback can still access the cbs member through a stored user pointer without checking whether the stream was removed. A compromised content process could trigger this race and cause a crash in the browser process.
Originally disclosed on Mozilla
- Fixed in 8 months
- Paid in 6 months
- Disclosed after 8 months
Created attachment 9407244
patch.diff
It's a typical scenario of use-after-free. In |process_msg()|[1], |ServerStream| is removed from |streams| while handling the |StreamDestroy| message[2]. And then in |data_callback()|[3], |cbs|, which is a member of the |ServerStream| and is stored in |user_ptr|, is accessed without any check. In addition, you can see that the |cbs| is stored into |user_ptr| in [4].
I think that a UAF issue might exist not only at this location but also in other parts where |cbs| is accessed via |user_ptr| like [5], [6], etc.
I attempted to get ASAN report but it didn't work like bug 1902307. From my analysis, it appears that Nightly ASAN Build can trace the deallocation when |ServerStream| is removed. However, ASAN doesn't seem to function when the |cbs| is accessed in |data_callback()|.
Instead, I've attached the callstacks and assembly contexts from the crash.
With patch.diff, you can emulate a compromised Content Process to trigger the UAF. Given that this vulnerability involves a race condition, I've inserted some Sleep statements into both Content Process and Browser Process codebases to increase the success rate.
Although it is not a fundamental solution, I suggest adding some checks to ensure that corresponding |ServerStream| in |streams| has not been removed before accessing |cbs| via |user_ptr|.
[1]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#463
[2]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#545
[3]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#226
[4]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#833
[5]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#905
[6]: https://searchfox.org/mozilla-central/source/third_party/rust/audioipc2-server/src/server.rs#913
REPRODUCTION CASE
Type of vulnerability: Browser Process
Operating System: Win11 x64
To reproduce the crash please follow these steps:
1. Apply patch.diff
2. Open a video in firefox browser e.g. the attached mp4 file, or video website
// patch.diff emulates a compromised content process and adds some sleeps to improve the success rate
When running this PoC on release build, you can find that a crash happens due to the effect of UAF.
For the exact cause, please refer to the attached call stack file or take a look using a debugger.
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 code removes the ServerStream from the streams map on StreamDestroy but data_callback still dereferences the cbs pointer stored in user_ptr without verifying the stream still exists.
Impact
A compromised content process could trigger a use-after-free in the browser process, causing a crash; the report does not claim code execution.
What the attacker needed
Compromised content process; race between destroy and callback
The fix
The reporter suggests adding checks that the corresponding ServerStream has not been removed before accessing cbs via user_ptr, though this is not described as a fundamental fix.
How it was found
- Apply the provided patch that emulates a compromised content process and adds sleeps
- Open a video in the Firefox browser, such as the attached mp4 file or a video website
- Observe the crash caused by the use-after-free on a release build
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 use-after-free happens when a program frees an object but keeps using it, like deleting a file and then trying to open it. Here the audio server frees a stream record when told to destroy it, but a callback that runs later still reads data from that freed record. Because the two actions can overlap in time (a race), a malicious page process could make the browser crash.
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.