Skip to content
Race condition Advisory Advanced CVE-2026-5902

Race in Media (CVE-2026-5902)

The Android NDK video encoder writes encoded data into shared memory and then re-reads it to parse metadata, but the renderer retains write access to that memory. A compromised renderer can race to overwrite the buffer with crafted bitstream data, feeding attacker-controlled input to H.264, HEVC, VP9, and AV1 parsers in the GPU process.

Luke Francis Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 57 days

VULNERABILITY DETAILS

The Android NDK Video Encode Accelerator (NdkVideoEncodeAccelerator) writes encoded bitstream data into an UnsafeSharedMemoryRegion, then re-reads from that same shared memory to parse temporal scalability metadata. The renderer retains write access to this region. A compromised renderer can mutate the buffer contents between the encoder's write and the metadata parse, feeding attacker-controlled bitstream data to H.264, HEVC, VP9, and AV1 parsers running in the GPU process.

The vulnerable code is in media/gpu/android/ndk_video_encode_accelerator.cc:

  • Line 1460: Encoder output copied into shared memory via output_dst.copy_prefix_from
  • Line 1487: svc_parser_->ParseChunk() re-reads from the same shared memory span

Between these two lines, the renderer can overwrite the buffer with crafted NALUs/OBUs. The parsers (H264Parser, H265NaluParser, Vp9Parser, libgav1 ObuParser) were not designed to handle adversarial input on this code path. They expect trusted encoder output.

Other platform encoders are not affected. VAAPI derives metadata from encoder-internal state (vaapi_video_encode_accelerator.cc:524-556). V4L2 parses from its kernel mmap'd capture buffer before copying to shared memory (v4l2_video_encode_accelerator.cc:1467-1485). MediaFoundation parses from its MF COM buffer (media_foundation_video_encode_accelerator_win.cc:2398-2413). Only the NDK path parses from the shared memory span after writing to it.

The fix is to move the ParseChunk() call to operate on the MediaCodec output buffer (out_buffer_data) before copying to shared memory, matching the pattern used by V4L2 and MediaFoundation.

VERSION

Chrome Version: trunk (verified against current main branch) Operating System: Android (all versions using NDK MediaCodec encoder)

REPRODUCTION CASE

A standalone PoC demonstrates the race condition by simulating the GPU and renderer threads operating on the same UnsafeSharedMemoryRegion. Results: 1.9 million race wins out of 62 million iterations (3.06% hit rate) in 2 seconds.

The PoC is attached. It can also be built as a Chromium unit test.

The race window exists between ndk_video_encode_accelerator.cc lines 1460 and 1487. In real exploitation, the attacker substitutes arbitrary H.264/VP9/AV1 bitstream data, feeding crafted input to TemporalScalabilityIdExtractor::ParseChunk() (media/parsers/temporal_scalability_id_extractor.cc:56), which dispatches to:

  • ParseH264 (line 77): H264Parser::AdvanceToNextNALU on attacker data
  • ParseHEVC (line 108): H265NaluParser::AdvanceToNextNALU on attacker data
  • ParseVP9 (line 132): Vp9Parser::ParseNextFrame on attacker data, reads ref_frame_idx[] used to index into vp9_ref_buffer_[kVp9NumRefFrames=8]
  • ParseAV1 (line 175): libgav1::ObuParser::ParseOneFrame on attacker data, complex parser touching DecoderState and BufferPool

The VP9 and AV1 paths maintain persistent reference frame state across frames, so corrupted state cascades to subsequent frames.

FOR CRASHES, PLEASE INCLUDE THE FOLLOWING ADDITIONAL INFORMATION

Type of crash: GPU process. Attacker-controlled data reaches bitstream parsers. Impact depends on parser robustness to adversarial input. Potential outcomes include wrong metadata propagation, parser state corruption, and possible out-of-bounds reads in complex parsers (especially libgav1).

CREDIT INFORMATION

Reporter credit: Luke Francis

The original report as published on the Chromium issue tracker, by Luke Francis. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 NDK encoder parses metadata from a shared memory buffer that the renderer can still write to, instead of parsing from the encoder's own output buffer before copying.

Impact

A compromised renderer could feed crafted bitstream data to parsers in the GPU process, potentially causing wrong metadata, parser state corruption, or out-of-bounds reads, though the exact impact depends on parser robustness.

What the attacker needed

Compromised renderer; Android device with NDK MediaCodec encoder

The fix

The fix is to move the ParseChunk() call to operate on the MediaCodec output buffer before copying to shared memory, matching the pattern used by V4L2 and MediaFoundation.

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 video encoder on Android writes data into a shared memory area, then reads it back to extract metadata. The renderer process, which is less trusted, can still write to that same memory. If an attacker controls the renderer, they can quickly change the data between the write and the read, so the GPU process parses malicious video data.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by Luke Francis

View all

5 more disclosed reports, best first.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.