[macOS] Compromised content process can trigger AppleVTDecoder UAF in RDD via repeated PRemoteDecoder Init
A compromised web content process could send an unexpected second Init to the PRemoteDecoder actor, and the parent-side RemoteDecoderParent did not reject it. On macOS this caused AppleVTDecoder to replace its VideoToolbox session without releasing the old one, so a pending callback later dereferenced the freed decoder, producing a heap-use-after-free in the RDD process.
- Fixed in 11 days
- Paid in 21 days
- Disclosed after 11 days
Created attachment 9618316 apple-vt-duplicate-init-minimal-reproducer.patch
Summary
A compromised web content process can use a legitimate PRemoteDecoder actor
to send Construct -> Init -> Decode(one H.264 sample) -> Init -> Shutdown.
RemoteDecoderParent does not enforce one-time initialization or reject this
cross-operation sequence. On macOS, the second AppleVTDecoder::Init creates a
new VideoToolbox decompression session by writing through mSession.Receive()
without invalidating or releasing the existing session.
The old session remains alive with a callback record containing the raw
AppleVTDecoder*. A following Shutdown destroys the decoder and only the new
session. When the old session completes its pending asynchronous frame, the
real VideoToolbox callback dereferences the freed decoder.
I reproduced this as a heap-use-after-free in the Firefox RDD process twice with an optimized ASan build, using one sample, no seek threshold, and no callback gate. This demonstrates attacker-triggerable memory corruption across the content-to-RDD IPC boundary. I demonstrated a UAF read and RDD abnormal shutdown; I did not attempt code execution or parent-process escape.
Security boundary and precondition
The precondition is a compromised untrusted web content process. The attacker
uses a legitimate PRemoteDecoder actor created for normal H.264 playback and
sends a raw lifecycle sequence that the normal child implementation does not
send:
Construct -> Init1 -> Decode(one sample) -> 1 ms ->
Init2 + Shutdown (back-to-back) -> __delete__
No forged actor identity or privileged preference is required. On macOS,
media.rdd-process.enabled and media.rdd-applemedia.enabled are enabled by
default, so the vulnerable parent and AppleVTDecoder run in the RDD process.
The timing precondition is that the first VideoToolbox session still has an
asynchronous output callback pending when Init2 and Shutdown are dispatched.
Root cause
There are two missing release-enforced invariants.
First, RemoteDecoderParent::RecvInit checks only whether mDecoder is null.
It has a MOZ_DIAGNOSTIC_ASSERT for an overlapping pending Init, but it does
not reject a second Init after the first one has resolved. PRemoteDecoder
has no state machine limiting Init to the constructed state.
Second, AppleVTDecoder::Init always calls InitializeSession.
InitializeSession calls:
CMVideoFormatDescriptionCreate(..., mFormat.Receive());
VTDecompressionSessionCreate(..., &cb, mSession.Receive());
AutoTypeRef::Receive() checks that its object is uninitialized only with
MOZ_ASSERT. In an optimized build, the second Init therefore overwrites the
retained format/session pointers. The old VTDecompressionSession is neither
invalidated nor released, and its callback was created as:
VTDecompressionOutputCallbackRecord cb = {PlatformCallback, this};
AppleVTDecoder::ProcessShutdown invalidates and resets only the current
session. The orphaned first session can subsequently invoke
PlatformCallback(this, ...) after MediaDataDecoderProxy::Shutdown has
released the decoder.
Reproduction
Tested on macOS 26.5.2 arm64 at source commit:
272c6937c93bf6c3f132ce962d9ad7d798fce830
Firefox Nightly 155.0a1
BuildID 20260729203819
- Apply
apple-vt-duplicate-init-minimal-reproducer.patch. - Build with the attached optimized ASan mozconfig.
- From a directory containing both the source checkout as
firefox/and the attached audit files, run:
python3 -m http.server 8767 --bind 127.0.0.1
- Launch a fresh profile:
ASAN_OPTIONS=detect_leaks=0:abort_on_error=1:disable_coredump=0:allocator_may_return_null=1 \
ASAN_SYMBOLIZER_PATH="$HOME/.mozbuild/clang/bin/llvm-symbolizer" \
MOZ_REMOTE_DECODER_DUP_INIT_PROBE=1 \
MOZ_HEADLESS=1 \
./firefox/obj-vt-asan-opt/dist/Nightly.app/Contents/MacOS/firefox \
-no-remote -profile /path/to/fresh-profile \
http://127.0.0.1:8767/apple-vt-duplicate-init-audit/release-fixture-probe.html
The page loads Firefox's existing
dom/media/test/TestPatternHDR.mp4 fixture. The patch changes the child-side
sequence and adds observability logs to AppleVTDecoder. It does not block or
delay the callback, synthesize a callback, add a reference, manually free an
object, or set a seek threshold.
ASan result
The final minimal sequence reproduced 2/2 times. Both attached logs show:
CODEX_VT_PROBE: sending one sample without a seek threshold
CODEX_VT_PROBE: sending raw second Init and Shutdown back-to-back after 1 ms
CODEX_VT_PROBE: duplicate Init replacing existing session <session1>
CODEX_VT_PROBE: second Init resolved (type=1)
CODEX_VT_PROBE: duplicate Init created replacement session <session2>
without invalidating old session <session1>
CODEX_VT_PROBE: AppleVTDecoder destructor started for <decoder>
CODEX_VT_PROBE: raw Shutdown completed (resolved=1); deleting actor
CODEX_VT_PROBE: CALLBACK AFTER DECODER DESTRUCTOR STARTED (<same decoder>)
ERROR: AddressSanitizer: heap-use-after-free
READ of size 8
type=1 is the MediaResult arm, specifically the cancellation produced when
the immediately following RecvShutdown aborts the pending Init2 IPC resolver.
It is not a successful InitCompletionIPDL reply. Resolver cancellation does
not cancel the already-dispatched MediaDataDecoderProxy::Init operation.
Init2 and Shutdown are queued in that order on the same serial proxy task
queue. The two session-pointer markers show directly that Init2 replaced
session 1 with session 2 before Shutdown ran.
The invalid access is 176 bytes into a freed 472-byte AppleVTDecoder.
Read:
AppleVTDecoder::OutputFrame
PlatformCallback
VideoToolbox
Free:
AppleVTDecoder::Release
MediaDataDecoderProxy::Shutdown
Allocation:
AppleDecoderModule::CreateVideoDecoder
PDMFactory::CreateDecoder
RemoteVideoDecoderParent::RecvConstruct
The RDD process aborts and VideoBridgeParent reports
AbnormalShutdown.
Shipped-code check
I inspected the exact shipped tags:
FIREFOX_153_0_RELEASE
f1b6c0f86b96b7e0688c26f65803576f27cdaf88
FIREFOX_153_0_1_RELEASE
b77c477f461fd7f02ff6fcef80a4dd26398237be
Both contain the same duplicate-Init acceptance in
RemoteDecoderParent::RecvInit, the same AutoTypeRef::Receive assertion-only
guard, and the same AppleVT session replacement/callback behavior.
The ASan run used current source rather than a Release binary, but the reproducer intentionally uses only one sample and no seek threshold. It does not rely on the newer multi-sample seek/decode-pipelining path.
Related prior hardening
I found the public fix commit for private Bug 2027342:
a9bb9e500e26a38d7948b96b9340072114d5144c
That fix added null-decoder guards for messages after Shutdown, guarded
repeated/asynchronous Construct, and set mShutdown. This report uses a
second sequential Init while mDecoder is still non-null and mShutdown is
false, before Shutdown is processed:
Init1 completes -> Decode -> Init2 accepted/dispatched -> Shutdown
Therefore the post-Shutdown guard does not enforce the missing one-time initialization invariant. I am calling out the relationship explicitly because the issues are in the same actor lifecycle area, although this sequence and the AppleVT orphan-session UAF sink are distinct from the public patch.
I also reviewed Bug 1974365, public commit:
ac2d7f550d68618b119ccab5a64482db276bbaf4
That change tracks pending resolvers and adds MOZ_DIAGNOSTIC_ASSERTs for two
overlapping operations of the same kind. This sequence avoids that check:
Init1 has already resolved, then Init2 overlaps a Decode rather than another
unresolved Init. Neither public fix adds one-time initialization or a
cross-operation state machine.
Suggested fix
At the IPC boundary, add a release-enforced state machine and accept Init
exactly once:
Constructed -> Initializing -> Initialized -> ShuttingDown -> Shutdown/Failed
Allow Decode, Flush, Drain, and SetSeekThreshold only in
Initialized, and reject or close the actor on an invalid transition.
As defense in depth, AppleVTDecoder::Init should reject a second call when
mSession or mFormat is already set. If reinitialization is intended, it
must first wait for asynchronous frames, invalidate the old session, and
release it before replacing the callback refcon owner.
A regression test should send a raw second Init both after the first Init
has resolved and while a decode callback is pending.
Latest revalidation after update
I revalidated this after updating both the source checkout and installed Firefox Nightly.
Current source HEAD:
9d0c7d75f303b16930388cf1b8ef93d161d72c29
Installed official Nightly:
Firefox 155.0a1 BuildID 20260729095131 SourceStamp aea36f7c13cee7e70f5b27c073c11088c6e1725e
The five relevant upstream files are byte-for-byte identical between the previous source revision, the current source HEAD, and the installed Nightly SourceStamp. I rebuilt the optimized ASan configuration at the current HEAD and reproduced the same natural heap-use-after-free on the first run.
The new log has SHA-256:
fda012ba8b463588274ddfd7b90e57687e3b1dca475cfef03163d82e777e5a96
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 two missing invariants: the IPC parent accepted a second Init after the first had resolved, and AppleVTDecoder::Init overwrote its session pointer without invalidating or releasing the existing VideoToolbox session whose callback still held a raw pointer to the decoder.
Impact
A compromised content process could trigger a heap-use-after-free read in the RDD process and cause it to abort; the author demonstrated only a UAF read and abnormal shutdown, not code execution or a parent-process escape.
What the attacker needed
Compromised content process; macOS with default RDD settings; pending async VideoToolbox callback
The fix
The report suggests enforcing a release-level state machine at the IPC boundary so Init is accepted exactly once, and as defence in depth rejecting a second AppleVTDecoder::Init while a session already exists.
How it was found
- Apply the attached minimal reproducer patch and build with the optimized ASan configuration.
- Serve the audit fixture directory over a local HTTP server.
- Launch a fresh-profile headless Nightly pointed at the probe page, which loads the existing H.264 test fixture.
- The patched child sends Construct, Init, one decode sample, then a second Init and Shutdown back-to-back after a short delay.
- Observe the ASan heap-use-after-free report and the RDD process abnormal shutdown.
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 splits its work into separate processes, and a web page's content process is not trusted. A decoder object in a more privileged process accepted a second 'start' command it should have refused, leaving an old decoding session pointing at memory that had already been freed. When that old session finished its work, it wrote into freed memory, which is a use-after-free and can crash or corrupt the program.
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.