Skip to content

Commit bb0c912

Browse files
evliu-googleMichal Klocek
authored andcommitted
[470][Backport] CVE-2025-8292: Use after free in Media Stream
Cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/6712212: Fix potential UAF in MediaStreamTrackImpl This CL fixes a potential UAF vulnerability in MediaStreamTrackImpl where pointers to the SpeechRecognitionMediaStreamAudioSinks that are owned by the MediaStreamTrackImpl could potentially be accessed after the sinks are destroyed. Fixed: 426054987 Change-Id: I453160a8eed7926e2cc3500260de04d2722c98e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6712212 Commit-Queue: Evan Liu <evliu@google.com> Reviewed-by: Mark Foltz <mfoltz@chromium.org> Cr-Commit-Position: refs/heads/main@{#1486476} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/665071 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
1 parent b99cfd6 commit bb0c912

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

chromium/third_party/blink/renderer/modules/mediastream/media_stream_track_impl.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,19 @@ CaptureHandle* MediaStreamTrackImpl::getCaptureHandle() const {
752752
return capture_handle;
753753
}
754754

755+
void MediaStreamTrackImpl::Dispose() {
756+
// `MediaStreamTrackImpl` and the `SpeechRecognitionMediaStreamAudioSink`
757+
// which it owns may be destroyed before the `MediaStreamAudioTrack`. Remove
758+
// the sinks before destroying them to prevent `MediaStreamAudioTrack` from
759+
// using them after destruction.
760+
if (MediaStreamAudioTrack* audio_track =
761+
MediaStreamAudioTrack::From(Component())) {
762+
for (SpeechRecognitionMediaStreamAudioSink* sink : registered_sinks_) {
763+
audio_track->RemoveSink(sink);
764+
}
765+
}
766+
}
767+
755768
ScriptPromise<IDLUndefined> MediaStreamTrackImpl::applyConstraints(
756769
ScriptState* script_state,
757770
const MediaTrackConstraints* constraints) {

chromium/third_party/blink/renderer/modules/mediastream/media_stream_track_impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class ScriptState;
5757
// Primary implementation of the MediaStreamTrack interface and idl type.
5858
class MODULES_EXPORT MediaStreamTrackImpl : public MediaStreamTrack,
5959
public MediaStreamSource::Observer {
60+
USING_PRE_FINALIZER(MediaStreamTrackImpl, Dispose);
61+
6062
public:
6163
// Create a MediaStreamTrackImpl of the appropriate type for the display
6264
// surface type.
@@ -166,6 +168,8 @@ class MODULES_EXPORT MediaStreamTrackImpl : public MediaStreamTrack,
166168
friend class CanvasCaptureMediaStreamTrack;
167169
friend class InternalsMediaStream;
168170

171+
void Dispose();
172+
169173
// MediaStreamTrack
170174
void applyConstraints(ScriptPromiseResolver<IDLUndefined>*,
171175
const MediaTrackConstraints*) override;

0 commit comments

Comments
 (0)