Skip to content
Memory corruption Advisory Advanced CVE-2025-13638

Use after free in Media Stream (CVE-2025-13638)

A use-after-free occurs in WebMediaPlayerMS::OnFirstFrameReceived because a garbage collection can be triggered while an object is still referenced. An attacker could potentially exploit this to cause a crash or possibly execute arbitrary code in the renderer.

sherkito Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 2 months

Steps to reproduce the problem

  1. chrome.exe --js-flags="--stress-incremental-marking --expose-gc" --no-sandbox

Problem Description

In the MaybeCreateWatchTimeReporter function below, a call to GarbageCollector is possible, which causes Use-After-Free.

C++
void WebMediaPlayerMS::OnFirstFrameReceived(
    media::VideoTransformation video_transform,
    bool is_opaque) {
  DVLOG(1) << __func__;
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);

  has_first_frame_ = true;
  OnTransformChanged(video_transform);
  OnOpacityChanged(is_opaque);

  if (use_surface_layer_)
    ActivateSurfaceLayerForVideo(video_transform);

  SetReadyState(WebMediaPlayer::kReadyStateHaveMetadata);
  SetReadyState(WebMediaPlayer::kReadyStateHaveEnoughData);
  TriggerResize();
  ResetCanvasCache();
  MaybeCreateWatchTimeReporter();

The most annoying code in the code is the function below called from the WebMediaPlayerMS::SetReadyState function, and the ScheduleNamedEvent function can be avoided by satisfying the tracks_are_ready condition in the function below.

C++
void HTMLMediaElement::SetReadyState(ReadyState state) {
  '''
  bool was_potentially_playing = PotentiallyPlaying();

  ReadyState old_state = ready_state_;
  ReadyState new_state = state;

  bool tracks_are_ready = TextTracksAreReady();

  '''
  if (ready_state_ == kHaveEnoughData && old_state < kHaveEnoughData &&
      tracks_are_ready) {
    if (old_state <= kHaveCurrentData) {
      ScheduleNamedEvent(event_type_names::kCanplay);
      if (is_potentially_playing)
        ScheduleNotifyPlaying();
    }

    if (autoplay_policy_->RequestAutoplayByAttribute()) {
      paused_ = false;
      SetShowPosterFlag(false);
      GetCueTimeline().InvokeTimeMarchesOn();
      ScheduleNamedEvent(event_type_names::kPlay);
      ScheduleNotifyPlaying();
      can_autoplay_ = false;
    }

    ScheduleNamedEvent(event_type_names::kCanplaythrough);
  }

  UpdatePlayState();
}

The exact location of the function that calls the GarbageCollector can be found through the AudioComponents or VideoComponents function call in the WebMediaPlayerMS::GetMediaStreamType function called by WebMediaPlayerMS::MaybeCreateWatchTimeReporter.

C++
WebMediaPlayerMS::GetMediaStreamType() {
  if (web_stream_.IsNull())
    return std::nullopt;

  // If either the first video or audio source is remote, the media stream is
  // of remote source.
  MediaStreamDescriptor& descriptor = *web_stream_;
  MediaStreamSource* media_source = nullptr;
  if (HasVideo()) {
    auto video_components = descriptor.VideoComponents();
    DCHECK_GT(video_components.size(), 0U);
    media_source = video_components[0]->Source();
  } else if (HasAudio()) {
    auto audio_components = descriptor.AudioComponents();
    DCHECK_GT(audio_components.size(), 0U);
    media_source = audio_components[0]->Source();
  }

If the trigger doesn't proceed smoothly, try using native Chromium instead of ASAN Chromium. Depending on your computer's specifications, there may still be areas where the task order and GC condition processing probability are low. We will improve this in the future and re-upload the proof-of-concept (PoC).

The Chromium commit that triggered this vulnerability is 06773e4fd40f4b8ad8a3c94a86ff14613b626c8e

Summary

Use-After-Free in WebMediaPlayerMS::OnFirstFrameReceived

Custom Questions

Type of crash:

Renderer

Crash state:

An action occurs that references a freed object member object.

Reporter credit:

sherkito

Additional Data

Category: Security
Chrome Channel: Not sure
Regression: N/A \

The original report as published on the Chromium issue tracker, by sherkito. 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

Likely, the MaybeCreateWatchTimeReporter function can trigger garbage collection via GetMediaStreamType, which frees an object that is still being used in OnFirstFrameReceived.

Impact

This could lead to a renderer crash and potentially allow an attacker to execute arbitrary code, though the report does not demonstrate full exploitation.

What the attacker needed

Chrome with specific JS flags; Trigger media stream first frame

How it was found

  1. Launch Chrome with JavaScript flags to stress incremental marking and expose garbage collection, and disable the sandbox.
  2. Trigger the media stream first frame received path, which calls MaybeCreateWatchTimeReporter and may cause garbage collection.

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 is a bug where a program keeps using memory after it has been freed, which can lead to crashes or let an attacker run their own code. Here, a media player function can trigger garbage collection (automatic memory cleanup) while still using an object, so the object gets freed too early.

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.

More by sherkito

View all

3 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.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.