Compromised content process can trigger a parent-process out-of-bounds write in the AudioIPC server by sending mismatched StreamCreate and StreamInit output parameters
A compromised content process can send mismatched audio stream parameters to the parent-process AudioIPC server, causing the server to size an internal buffer based on the first message while the real backend buffer is allocated from the second message. When audio playback starts, the server copies bytes from shared memory past the end of the backend buffer, resulting in a parent-process out-of-bounds write.
Originally disclosed on Mozilla
- Fixed in 23 days
- Paid in 3 months
- Disclosed after 23 days
Created attachment 9589265
repro.patch
Platform: Desktop
Version: Firefox Nightly 153.0a1 (commit 1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1)
Summary:
A compromised content process can make Firefox's parent-process AudioIPC server accept inconsistent audio stream setup data. The server then sizes an internal audio copy as if the stream had many more output channels than the real backend buffer was allocated for. When audio playback starts, the server copies bytes controlled by the content process from AudioIPC shared memory past the end of that backend buffer, causing a parent-process out-of-bounds write.
Steps to Reproduce:
1. Apply the attached patch to a Firefox source checkout:
`git apply /absolute/path/to/repro.patch`
2. Build Firefox with ASan. The tested mozconfig was:
'''
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-asan
ac_add_options --enable-address-sanitizer
ac_add_options --disable-jemalloc
ac_add_options --disable-crashreporter
ac_add_options --disable-elf-hack
ac_add_options --disable-install-strip
ac_add_options --enable-debug-symbols=-gline-tables-only
'''
Build command:
`MOZCONFIG=mozconfig-asan ./mach build`
3. Run the patched ASan build with the repro hook enabled:
`MOZCONFIG=mozconfig-asan PULSE_MEMPOOL_DISABLE=1 MOZ_AUDIOIPC_STREAM_CREATE_MISMATCH_REPRO=1 ./mach run --temp-profile -- --headless file:///absolute/path/to/trigger.html`
Replace `/absolute/path/to/trigger.html` with the absolute path to the attached trigger page.
`PULSE_MEMPOOL_DISABLE=1` is used only to make the bug easier for ASan to observe on Linux/PulseAudio. It makes PulseAudio use a normal heap-backed output buffer with ASan redzones, so the out-of-bounds write is reported deterministically by ASan.
The vulnerability does not depend on `PULSE_MEMPOOL_DISABLE=1`. The content process still sends inconsistent AudioIPC stream parameters, and the parent-side AudioIPC server still computes an oversized copy length and writes past the true end of the backend output buffer. Without `PULSE_MEMPOOL_DISABLE=1`, PulseAudio may place that backend buffer in its shared-memory/mempool allocator instead of a normal heap allocation, so this local ASan build may not report the overwrite even though the same out-of-bounds write path is reached.
Security Impact:
A compromised content process can turn the normal AudioIPC connection into a parent-process out-of-bounds write.
With PulseAudio's default mempool enabled (without `PULSE_MEMPOOL_DISABLE=1`), the destination may be PulseAudio-managed shared-memory/mempool storage rather than a normal malloc allocation. Corrupting adjacent PulseAudio mempool or memblock metadata could increase exploitability and, when combined with another bug or a suitable memory disclosure/control primitive, could be used as part of an arbitrary address write chain.
Technical Analysis:
1. Normal compromised-content-process reachability
The content process obtains its AudioIPC connection through the normal `PContent::CreateAudioIPCConnection` path.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/dom/ipc/PContent.ipdl#1170
'''ipdl
async CreateAudioIPCConnection() returns (FileDescOrError fd);
'''
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/dom/ipc/ContentParent.cpp#5131-5134
'''cpp
mozilla::ipc::IPCResult ContentParent::RecvCreateAudioIPCConnection(
CreateAudioIPCConnectionResolver&& aResolver) {
FileDescriptor fd = CubebUtils::CreateAudioIPCConnection(OtherPid());
...
}
'''
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/dom/media/CubebUtils.cpp#603-617
'''cpp
rawFD = audioipc2::audioipc2_server_new_client(
sServerHandle,
aRemotePid,
sAudioIPCShmAreaSize);
'''
2. The server stores output frame size from the first client-controlled message
The AudioIPC server receives stream format information in two different RPC messages. `CubebServer::process_stream_create()` first stores `output_frame_size` in `ServerStreamCallbacks` from `StreamCreateParams`, which are supplied by the remote AudioIPC client.
Because `StreamCreateParams` come from the remote AudioIPC client, a compromised content process can make this first message describe a large output channel count. The value is stored before the real cubeb stream is initialized and is later used to size the parent-process copy.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/third_party/rust/audioipc2-server/src/server.rs#728-775
'''rust
fn process_stream_create(&mut self, params: &StreamCreateParams) -> Result<ClientMessage> {
let output_frame_size = params
.output_stream_params
.as_ref()
.map(StreamParams::frame_size_in_bytes);
...
let cbs = Box::new(ServerStreamCallbacks {
input_frame_size,
output_frame_size,
shm,
...
});
}
'''
3. The actual backend stream is created from a second message
`CubebServer::process_stream_init()` validates the later `StreamInitParams`, including `channels <= 64`, but it does not compare those validated parameters with the earlier `StreamCreateParams`. The actual cubeb/PulseAudio stream is then created from the later `StreamInitParams`. In the repro, the real backend stream is initialized from the smaller 1-channel `StreamInitParams`.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/third_party/rust/audioipc2-server/src/server.rs#795-876
'''rust
fn process_stream_init(..., params: &StreamInitParams) -> Result<ClientMessage> {
fn valid_stream_params(p: &StreamParams) -> bool {
const MAX_CHANNELS: u32 = 64;
...
p.channels >= 1 && p.channels <= MAX_CHANNELS && ...
}
for p in params.input_stream_params.iter().chain(params.output_stream_params.iter()) {
if !valid_stream_params(p) {
...
}
}
let stream = context.stream_init(
stream_name,
input_device,
input_stream_params,
output_device,
output_stream_params,
latency,
Some(data_cb_c),
Some(state_cb_c),
user_ptr,
);
}
'''
Because the two messages are not checked for consistency, a compromised content process can send:
* `StreamCreate`: a 128-channel output stream, causing a large stored `output_frame_size`
* `StreamInit`: a 1-channel output stream, causing the real backend output buffer to be sized for 1 channel
4. The callback builds a Rust slice using the stale `StreamCreate` size
When the audio backend invokes the server callback, `data_cb_c()` receives the actual backend `output_buffer`, but it constructs the Rust `output` slice length from `ServerStreamCallbacks.output_frame_size`, which came from the earlier `StreamCreateParams`. The backend-provided `output_buffer` is from the stream created with `StreamInitParams`, but the slice length is computed using the older `StreamCreate`-derived size.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/third_party/rust/audioipc2-server/src/server.rs#902-923
'''rust
unsafe extern "C" fn data_cb_c(..., output_buffer: *mut c_void, nframes: c_long) -> c_long {
let cbs = &mut *(user_ptr as *mut ServerStreamCallbacks);
...
let output: &mut [u8] = if output_buffer.is_null() {
&mut []
} else {
let nbytes = nframes * cbs.output_frame_size.unwrap_or(0) as c_long;
slice::from_raw_parts_mut(output_buffer as *mut u8, nbytes as usize)
};
cbs.data_callback(input, output, nframes as isize) as c_long
}
'''
5. The final copy checks the wrong destination size and copies bytes controlled by the content process
`ServerStreamCallbacks::data_callback()` checks `nbytes` against `output.len()` and the AudioIPC shared-memory size. However, `output.len()` is already based on the stale, client-controlled `output_frame_size`; it is not the true length of the backend-provided output buffer. Therefore this check does not prove that the backend buffer is actually that large. The destination is the backend-provided parent-process buffer, and the source bytes come from AudioIPC shared memory mapped for the stream.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/third_party/rust/audioipc2-server/src/server.rs#281-298
'''rust
let Some(nbytes) = frames.checked_mul(output_frame_size) else {
return cubeb::ffi::CUBEB_ERROR.try_into().unwrap();
};
if nbytes > output.len() || nbytes > self.shm.get_size() {
return cubeb::ffi::CUBEB_ERROR.try_into().unwrap();
}
unsafe {
output[..nbytes].copy_from_slice(self.shm.get_slice(nbytes).unwrap());
}
'''
`SharedMemView::get_slice()` bounds only the shared-memory source mapping. It does not validate the true size of the backend output buffer.
https://searchfox.org/firefox-main/rev/1f7030c8de8f2b349c7d91d7b5a3253c109a1cc1/third_party/rust/audioipc2/src/shm.rs#231-240
'''rust
impl SharedMemView {
pub unsafe fn get_slice(&self, size: usize) -> Result<&[u8]> {
let map = slice::from_raw_parts(self.ptr as _, self.size);
if size <= self.size {
Ok(&map[..size])
} else {
Err(Error::Other("mmap size".into()))
}
}
}
'''
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 AudioIPC server stores the output frame size from the first client-controlled StreamCreate message and later uses it to size a copy into a backend buffer that was actually allocated according to a separate, smaller StreamInit message, without checking that the two messages agree.
Impact
A compromised content process can trigger a parent-process out-of-bounds write; with PulseAudio's default mempool, corrupting adjacent metadata could increase exploitability and, combined with another bug, could be used as part of an arbitrary address write chain.
What the attacker needed
Compromised content process; ability to send AudioIPC messages
How it was found
- Apply the attached patch to a Firefox source checkout.
- Build Firefox with AddressSanitizer using the provided mozconfig.
- Run the patched ASan build with the repro hook enabled and a trigger page.
- Observe the out-of-bounds write reported by ASan.
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.
Firefox separates web content into a less privileged 'content process' and a more privileged 'parent process'. The parent process provides an audio service that trusts some setup information from the content process. Here, the content process can send two conflicting audio setup messages, and the parent process uses the wrong one to decide how much data to copy, writing beyond the real audio buffer.
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.