Heap buffer overflow in WebRTC (CVE-2024-5493)
A heap buffer overflow write occurs in the libaom AV1 encoder when encoding a video frame via WebRTC. An attacker could potentially trigger this overflow by causing a crafted video frame to be encoded, leading to memory corruption.
Originally disclosed on Chrome VRP
- Fix shipped in 20 days
heap-buffer-overflow write in libaom tested os:ubuntu 22.04 tested chrome: Chromium 126.0.6461.0 Chromium 119.0.6041.0
repro steps: ./chrome --disable-gpu --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --incognito --user-data-dir=/tmp/xxs http://localhost:8880/crash.html
The buffer overflow will repro immediately.
==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x52e0000befe0 at pc 0x653bb5d6c90d bp 0x789085bb7c10 sp 0x789085bb7c08 WRITE of size 4 at 0x52e0000befe0 thread T75 (CodecWorker) #0 0x653bb5d6c90c in fill_variance ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:103:23 #1 0x653bb5d6c90c in fill_variance_4x4avg ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:420:5 #2 0x653bb5d6c90c in fill_variance_tree_leaves ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1166:13 #3 0x653bb5d6c90c in av1_choose_var_based_partitioning ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1744:3 #4 0x653bb5b05112 in encode_nonrd_sb ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:555:5 #5 0x653bb5b05112 in encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1246:7 #6 0x653bb5b05112 in av1_encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1435:3 #7 0x653bb5bc3223 in enc_row_mt_worker_hook ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:721:5 #8 0x653ba3058319 in Execute ./../../media/base/codec_worker_impl.h:58:29 #9 0x653ba3058319 in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::ExecuteOnTaskRunner(AVxWorker*) ./../../media/base/codec_worker_impl.h:102:5 #10 0x653ba3058a44 in Invoke<void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::)(AVxWorker ), media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2> , AVxWorker > ./../../base/functional/bind_internal.h:738:12 #11 0x653ba3058a44 in MakeItSo<void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::)(AVxWorker ), std::__Cr::tuple<base::internal::UnretainedWrapper<media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<AVxWorker, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0> > > ./../../base/functional/bind_internal.h:930:12 #12 0x653ba3058a44 in void base::internal::Invoker<base::internal::FunctorTraits<void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::&&)(AVxWorker), media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>, AVxWorker>, base::internal::BindState<true, true, false, void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::)(AVxWorker), base::internal::UnretainedWrapper<media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<AVxWorker, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void ()>::RunImpl<void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::)(AVxWorker), std::__Cr::tuple<base::internal::UnretainedWrapper<media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<AVxWorker, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, 0ul, 1ul>(void (media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::&&)(AVxWorker), std::__Cr::tuple<base::internal::UnretainedWrapper<media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<AVxWorker, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>&&, std::__Cr::integer_sequence<unsigned long, 0ul, 1ul>) ./../../base/functional/bind_internal.h:1067:14 #13 0x653bb27b2ec4 in Run ./../../base/functional/callback.h:156:12 #14 0x653bb27b2ec4 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:203:34 #15 0x653bb2814676 in RunTask<(lambda at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:475:11)> ./../../base/task/common/task_annotator.h:90:5 #16 0x653bb2814676 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:473:23 #17 0x653bb281358d in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:338:40 #18 0x653bb28153ba in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:0:0 #19 0x653bb26abd2d in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ./../../base/message_loop/message_pump_default.cc:40:55 #20 0x653bb2816026 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:645:12 #21 0x653bb274577f in base::RunLoop::Run(base::Location const&) ./../../base/run_loop.cc:134:14 #22 0x653bb28973ec in base::Thread::Run(base::RunLoop*) ./../../base/threading/thread.cc:338:13 #23 0x653bb289794e in base::Thread::ThreadMain() ./../../base/threading/thread.cc:410:3 #24 0x653bb28e0797 in base::(anonymous namespace)::ThreadFunc(void*) ./../../base/threading/platform_thread_posix.cc:101:13 #25 0x653ba04541b6 in asan_thread_start(void*) asan_rtl:28
0x52e0000befe0 is located 313 bytes after 43687-byte region [0x52e0000b4400,0x52e0000beea7) allocated by thread T2 (ThreadPoolForeg) here: #0 0x653ba045678f in __interceptor_malloc asan_rtl:3 #1 0x653bb5a0cbe9 in aom_memalign ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:59:22 #2 0x653bb5a0cbe9 in aom_malloc ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:67:40 #3 0x653bb5bb3afa in av1_init_tile_thread_data ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:1052:11 #4 0x653bb5a5b47b in encoder_encode ./../../third_party/libaom/source/libaom/av1/av1_cx_iface.c:3233:7 #5 0x653bb5a4b712 in aom_codec_encode ./../../third_party/libaom/source/libaom/aom/src/aom_encoder.c:191:11 #6 0x653bc54d33b2 in webrtc::(anonymous namespace)::LibaomAv1Encoder::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocatorwebrtc::VideoFrameType> const*) ./../../third_party/webrtc/modules/video_coding/codecs/av1/libaom_av1_encoder.cc:700:9 #7 0x653bc551c16c in webrtc::SimulcastEncoderAdapter::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocatorwebrtc::VideoFrameType> const*) ./../../third_party/webrtc/media/engine/simulcast_encoder_adapter.cc:546:33 #8 0x653bb5382be4 in webrtc::VideoStreamEncoder::EncodeVideoFrame(webrtc::VideoFrame const&, long) ./../../third_party/webrtc/video/video_stream_encoder.cc:2030:43 #9 0x653bb5380246 in webrtc::VideoStreamEncoder::MaybeEncodeVideoFrame(webrtc::VideoFrame const&, long) ./../../third_party/webrtc/video/video_stream_encoder.cc:1875:3 #10 0x653bb537cb24 in webrtc::VideoStreamEncoder::OnFrame(webrtc::Timestamp, bool, webrtc::VideoFrame const&) ./../../third_party/webrtc/video/video_stream_encoder.cc:1565:5 #11 0x653bb534a513 in OnFrameOnMainQueue ./../../third_party/webrtc/video/frame_cadence_adapter.cc:997:26 #12 0x653bb534a513 in operator() ./../../third_party/webrtc/video/frame_cadence_adapter.cc:965:5 #13 0x653bb534a513 in __invoke<(lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45)> ./../../third_party/libc++/src/include/__type_traits/invoke.h:150:25 #14 0x653bb534a513 in invoke<(lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45)> ./../../third_party/libc++/src/include/__functional/invoke.h:28:10 #15 0x653bb534a513 in InvokeR<void, (lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45), void> ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:132:3 #16 0x653bb534a513 in void absl::internal_any_invocable::RemoteInvoker<false, void, webrtc::(anonymous namespace)::FrameCadenceAdapterImpl::OnFrame(webrtc::VideoFrame const&)::$_1&&>(absl::internal_any_invocable::TypeErasedState*) ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:368:10 #17 0x653ba1c7cbc8 in operator() ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:876:1 #18 0x653ba1c7cbc8 in blink::WebRtcTaskQueue::RunTask(absl::AnyInvocable<void () &&>) ./../../third_party/webrtc_overrides/task_queue_factory.cc:100:5 #19 0x653ba1c7e517 in Invoke<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), blink::WebRtcTaskQueue , absl::AnyInvocable<void () &&> > ./../../base/functional/bind_internal.h:738:12 #20 0x653ba1c7e517 in MakeItSo<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), std::__Cr::tuple<base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&> > > ./../../base/functional/bind_internal.h:930:12 #21 0x653ba1c7e517 in RunImpl<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), std::__Cr::tuple<base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&> >, 0UL, 1UL> ./../../base/functional/bind_internal.h:1067:14 #22 0x653ba1c7e517 in base::internal::Invoker<base::internal::FunctorTraits<void (blink::WebRtcTaskQueue::&&)(absl::AnyInvocable<void () &&>), blink::WebRtcTaskQueue, absl::AnyInvocable<void () &&>&&>, base::internal::BindState<true, true, false, void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&>>, void ()>::RunOnce(base::internal::BindStateBase) ./../../base/functional/bind_internal.h:980:12 #23 0x653bb27b2ec4 in Run ./../../base/functional/callback.h:156:12 #24 0x653bb27b2ec4 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:203:34 #25 0x653bb283519b in RunTask<(lambda at ../../base/task/thread_pool/task_tracker.cc:680:35)> ./../../base/task/common/task_annotator.h:90:5 #26 0x653bb283519b in base::internal::TaskTracker::RunTaskImpl(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::internal::SequenceToken const&) ./../../base/task/thread_pool/task_tracker.cc:679:19 #27 0x653bb28353ec in base::internal::TaskTracker::RunSkipOnShutdown(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::internal::SequenceToken const&) ./../../base/task/thread_pool/task_tracker.cc:664:3 #28 0x653bb28346f5 in RunTaskWithShutdownBehavior ./../../base/task/thread_pool/task_tracker.cc:694:7 #29 0x653bb28346f5 in base::internal::TaskTracker::RunTask(base::internal::Task, base::internal::TaskSource*, base::TaskTraits const&) ./../../base/task/thread_pool/task_tracker.cc:521:5 #30 0x653bb2833784 in base::internal::TaskTracker::RunAndPopNextTask(base::internal::RegisteredTaskSource) ./../../base/task/thread_pool/task_tracker.cc:416:5 #31 0x653bb28732b0 in base::internal::WorkerThread::RunWorker() ./../../base/task/thread_pool/worker_thread.cc:438:36 #32 0x653bb2872357 in base::internal::WorkerThread::RunPooledWorker() ./../../base/task/thread_pool/worker_thread.cc:322:3 #33 0x653bb2871e20 in base::internal::WorkerThread::ThreadMain() ./../../base/task/thread_pool/worker_thread.cc:302:7 #34 0x653bb28e0797 in base::(anonymous namespace)::ThreadFunc(void*) ./../../base/threading/platform_thread_posix.cc:101:13 #35 0x653ba04541b6 in asan_thread_start(void*) asan_rtl:28
Thread T75 (CodecWorker) created by T2 (ThreadPoolForeg) here: #0 0x653ba043c051 in ___interceptor_pthread_create asan_rtl:3 #1 0x653bb28dfcf0 in base::(anonymous namespace)::CreateThread(unsigned long, bool, base::PlatformThreadBase::Delegate*, base::PlatformThreadHandle*, base::ThreadType, base::MessagePumpType) ./../../base/threading/platform_thread_posix.cc:146:13 #2 0x653bb2896703 in base::Thread::StartWithOptions(base::Thread::Options) ./../../base/threading/thread.cc:211:26 #3 0x653bb2896018 in base::Thread::Start() ./../../base/threading/thread.cc:169:10 #4 0x653ba305788b in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::CodecWorkerImpl() ./../../media/base/codec_worker_impl.h:43:13 #5 0x653ba30572da in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::Reset(AVxWorker*) ./../../media/base/codec_worker_impl.h:124:57 #6 0x653bb5bb4491 in av1_create_workers ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:1104:12 #7 0x653bb5a5b441 in encoder_encode ./../../third_party/libaom/source/libaom/av1/av1_cx_iface.c:3232:7 #8 0x653bb5a4b712 in aom_codec_encode ./../../third_party/libaom/source/libaom/aom/src/aom_encoder.c:191:11 #9 0x653bc54d33b2 in webrtc::(anonymous namespace)::LibaomAv1Encoder::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocatorwebrtc::VideoFrameType> const*) ./../../third_party/webrtc/modules/video_coding/codecs/av1/libaom_av1_encoder.cc:700:9 #10 0x653bc551c16c in webrtc::SimulcastEncoderAdapter::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocatorwebrtc::VideoFrameType> const*) ./../../third_party/webrtc/media/engine/simulcast_encoder_adapter.cc:546:33 #11 0x653bb5382be4 in webrtc::VideoStreamEncoder::EncodeVideoFrame(webrtc::VideoFrame const&, long) ./../../third_party/webrtc/video/video_stream_encoder.cc:2030:43 #12 0x653bb5380246 in webrtc::VideoStreamEncoder::MaybeEncodeVideoFrame(webrtc::VideoFrame const&, long) ./../../third_party/webrtc/video/video_stream_encoder.cc:1875:3 #13 0x653bb537cb24 in webrtc::VideoStreamEncoder::OnFrame(webrtc::Timestamp, bool, webrtc::VideoFrame const&) ./../../third_party/webrtc/video/video_stream_encoder.cc:1565:5 #14 0x653bb534a513 in OnFrameOnMainQueue ./../../third_party/webrtc/video/frame_cadence_adapter.cc:997:26 #15 0x653bb534a513 in operator() ./../../third_party/webrtc/video/frame_cadence_adapter.cc:965:5 #16 0x653bb534a513 in __invoke<(lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45)> ./../../third_party/libc++/src/include/__type_traits/invoke.h:150:25 #17 0x653bb534a513 in invoke<(lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45)> ./../../third_party/libc++/src/include/__functional/invoke.h:28:10 #18 0x653bb534a513 in InvokeR<void, (lambda at ../../third_party/webrtc/video/frame_cadence_adapter.cc:951:45), void> ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:132:3 #19 0x653bb534a513 in void absl::internal_any_invocable::RemoteInvoker<false, void, webrtc::(anonymous namespace)::FrameCadenceAdapterImpl::OnFrame(webrtc::VideoFrame const&)::$_1&&>(absl::internal_any_invocable::TypeErasedState*) ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:368:10 #20 0x653ba1c7cbc8 in operator() ./../../third_party/abseil-cpp/absl/functional/internal/any_invocable.h:876:1 #21 0x653ba1c7cbc8 in blink::WebRtcTaskQueue::RunTask(absl::AnyInvocable<void () &&>) ./../../third_party/webrtc_overrides/task_queue_factory.cc:100:5 #22 0x653ba1c7e517 in Invoke<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), blink::WebRtcTaskQueue , absl::AnyInvocable<void () &&> > ./../../base/functional/bind_internal.h:738:12 #23 0x653ba1c7e517 in MakeItSo<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), std::__Cr::tuple<base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&> > > ./../../base/functional/bind_internal.h:930:12 #24 0x653ba1c7e517 in RunImpl<void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), std::__Cr::tuple<base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&> >, 0UL, 1UL> ./../../base/functional/bind_internal.h:1067:14 #25 0x653ba1c7e517 in base::internal::Invoker<base::internal::FunctorTraits<void (blink::WebRtcTaskQueue::&&)(absl::AnyInvocable<void () &&>), blink::WebRtcTaskQueue, absl::AnyInvocable<void () &&>&&>, base::internal::BindState<true, true, false, void (blink::WebRtcTaskQueue::)(absl::AnyInvocable<void () &&>), base::internal::RetainedRefWrapperblink::WebRtcTaskQueue, absl::AnyInvocable<void () &&>>, void ()>::RunOnce(base::internal::BindStateBase) ./../../base/functional/bind_internal.h:980:12 #26 0x653bb27b2ec4 in Run ./../../base/functional/callback.h:156:12 #27 0x653bb27b2ec4 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:203:34 #28 0x653bb283519b in RunTask<(lambda at ../../base/task/thread_pool/task_tracker.cc:680:35)> ./../../base/task/common/task_annotator.h:90:5 #29 0x653bb283519b in base::internal::TaskTracker::RunTaskImpl(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::internal::SequenceToken const&) ./../../base/task/thread_pool/task_tracker.cc:679:19 #30 0x653bb28353ec in base::internal::TaskTracker::RunSkipOnShutdown(base::internal::Task&, base::TaskTraits const&, base::internal::TaskSource*, base::internal::SequenceToken const&) ./../../base/task/thread_pool/task_tracker.cc:664:3 #31 0x653bb28346f5 in RunTaskWithShutdownBehavior ./../../base/task/thread_pool/task_tracker.cc:694:7 #32 0x653bb28346f5 in base::internal::TaskTracker::RunTask(base::internal::Task, base::internal::TaskSource*, base::TaskTraits const&) ./../../base/task/thread_pool/task_tracker.cc:521:5 #33 0x653bb2833784 in base::internal::TaskTracker::RunAndPopNextTask(base::internal::RegisteredTaskSource) ./../../base/task/thread_pool/task_tracker.cc:416:5 #34 0x653bb28732b0 in base::internal::WorkerThread::RunWorker() ./../../base/task/thread_pool/worker_thread.cc:438:36 #35 0x653bb2872357 in base::internal::WorkerThread::RunPooledWorker() ./../../base/task/thread_pool/worker_thread.cc:322:3 #36 0x653bb2871e20 in base::internal::WorkerThread::ThreadMain() ./../../base/task/thread_pool/worker_thread.cc:302:7 #37 0x653bb28e0797 in base::(anonymous namespace)::ThreadFunc(void*) ./../../base/threading/platform_thread_posix.cc:101:13 #38 0x653ba04541b6 in asan_thread_start(void*) asan_rtl:28
Thread T2 (ThreadPoolForeg) created by T0 (chrome) here: #0 0x653ba043c051 in ___interceptor_pthread_create asan_rtl:3 #1 0x653bb28dfcf0 in base::(anonymous namespace)::CreateThread(unsigned long, bool, base::PlatformThreadBase::Delegate*, base::PlatformThreadHandle*, base::ThreadType, base::MessagePumpType) ./../../base/threading/platform_thread_posix.cc:146:13 #2 0x653bb287124a in base::internal::WorkerThread::Start(scoped_refptrbase::SingleThreadTaskRunner, base::WorkerThreadObserver*) ./../../base/task/thread_pool/worker_thread.cc:199:3 #3 0x653bb2837a1f in base::internal::ThreadGroup::BaseScopedCommandsExecutor::Flush() ./../../base/task/thread_pool/thread_group.cc:110:13 #4 0x653bb283751f in base::internal::ThreadGroup::BaseScopedCommandsExecutor::~BaseScopedCommandsExecutor() ./../../base/task/thread_pool/thread_group.cc:85:3 #5 0x653bb2868422 in ~SemaphoreScopedCommandsExecutor ./../../base/task/thread_pool/thread_group_semaphore.cc:48:3 #6 0x653bb2868422 in base::internal::ThreadGroupSemaphore::Start(unsigned long, unsigned long, base::TimeDelta, scoped_refptrbase::SingleThreadTaskRunner, base::WorkerThreadObserver*, base::internal::ThreadGroup::WorkerEnvironment, bool, std::__Cr::optionalbase::TimeDelta) ./../../base/task/thread_pool/thread_group_semaphore.cc:153:1 #7 0x653bb2847fe4 in base::internal::ThreadPoolImpl::Start(base::ThreadPoolInstance::InitParams const&, base::WorkerThreadObserver*) ./../../base/task/thread_pool/thread_pool_impl.cc:243:35 #8 0x653bbe10ad07 in content::ChildProcess::ChildProcess(base::ThreadType, std::__Cr::unique_ptr<base::ThreadPoolInstance::InitParams, std::__Cr::default_deletebase::ThreadPoolInstance::InitParams>) ./../../content/child/child_process.cc:118:20 #9 0x653bc9b9161b in content::RenderProcess::RenderProcess(std::__Cr::unique_ptr<base::ThreadPoolInstance::InitParams, std::__Cr::default_deletebase::ThreadPoolInstance::InitParams>) ./../../content/renderer/render_process.cc:18:7 #10 0x653bc9b90caf in content::RenderProcessImpl::RenderProcessImpl() ./../../content/renderer/render_process_impl.cc:112:7 #11 0x653bc9b912e0 in content::RenderProcessImpl::Create() ./../../content/renderer/render_process_impl.cc:223:31 #12 0x653bc9c1c5cc in content::RendererMain(content::MainFunctionParams) ./../../content/renderer/renderer_main.cc:296:53 #13 0x653bafe74269 in content::RunZygote(content::ContentMainDelegate*) ./../../content/app/content_main_runner_impl.cc:685:14 #14 0x653bafe757be in content::RunOtherNamedProcessTypeMain(std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>> const&, content::MainFunctionParams, content::ContentMainDelegate*) ./../../content/app/content_main_runner_impl.cc:789:12 #15 0x653bafe78351 in content::ContentMainRunnerImpl::Run() ./../../content/app/content_main_runner_impl.cc:1156:10 #16 0x653bafe72580 in content::RunContentProcess(content::ContentMainParams, content::ContentMainRunner*) ./../../content/app/content_main.cc:332:36 #17 0x653bafe72c0b in content::ContentMain(content::ContentMainParams) ./../../content/app/content_main.cc:345:10 #18 0x653ba048f408 in ChromeMain ./../../chrome/app/chrome_main.cc:192:12 #19 0x79a13e829d8f in __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/pwn11/asan-linux-release/chrome+0x243cc90c) (BuildId: 8fbb97da385e0340) Shadow bytes around the buggy address: 0x52e0000bed00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x52e0000bed80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x52e0000bee00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x52e0000bee80: 00 00 00 00 07 fa fa fa fa fa fa fa fa fa fa fa 0x52e0000bef00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x52e0000bef80: fa fa fa fa fa fa fa fa fa fa fa fa[fa]fa fa fa 0x52e0000bf000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x52e0000bf080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x52e0000bf100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x52e0000bf180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x52e0000bf200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb
==1==ADDITIONAL INFO
==1==Note: Please include this section with the ASan report. Task trace: #0 0x653ba3057e1a in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::ChangeStateImpl(AVxWorker*, AVxWorkerStatus) ./../../media/base/codec_worker_impl.h:91:11 #1 0x653bb5341bf3 in webrtc::(anonymous namespace)::FrameCadenceAdapterImpl::OnFrame(webrtc::VideoFrame const&) ./../../third_party/webrtc/video/frame_cadence_adapter.cc:951:11 #2 0x653bc587e0a5 in blink::MediaStreamVideoWebRtcSink::WebRtcVideoSourceAdapter::OnVideoFrameOnIO(scoped_refptrmedia::VideoFrame, base::TimeTicks) ./../../third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc:172:46
==1==END OF ADDITIONAL INFO ==1==ABORTING
Context
This is a Chrome VRP report for a heap buffer overflow in WebRTC, tracked as CVE-2024-5493 and rated high severity. The crash happens inside libaom, the AV1 codec library bundled with Chromium, while the browser is encoding a video stream for a WebRTC session. The faulting write is in the encoder's variance based partitioning code, which decides how a superblock is split into smaller blocks before encoding.
In normal use, a page that opens a WebRTC connection with an AV1 video track causes Chrome to feed captured frames into the libaom AV1 encoder. The encoder runs on worker threads and, for each superblock, computes variance statistics to choose a partition. The report shows that this path can write past the end of a heap allocation.
Setup
The researcher tested on Ubuntu 22.04 with two Chromium builds:
- Chromium 126.0.6461.0
- Chromium 119.0.6041.0
The ASan report's summary line shows the binary path /home/pwn11/asan-linux-release/chrome. The test page was served locally at http://localhost:8880/crash.html.
Finding it
The report does not describe how the researcher arrived at the bug, only the reproduction. What the ASan output shows is a write of size 4 landing 313 bytes after the end of a 43687-byte heap region. The write occurs on a CodecWorker thread inside fill_variance, reached through fill_variance_4x4avg, fill_variance_tree_leaves and [redacted]. The allocation that is overrun comes from av1_init_tile_thread_data, called from encoder_encode while the WebRTC LibaomAv1Encoder is encoding a frame.
Exploitation
Step 1: launch Chromium with fake media devices
The reproduction uses a single command line that starts Chromium with a fake camera and microphone, so no real capture device is needed, and points it at the local test page:
./chrome --disable-gpu --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --incognito --user-data-dir=/tmp/xxs http://localhost:8880/crash.html
The flags do the following:
--disable-gpudisables GPU acceleration.--use-fake-ui-for-media-streamauto-accepts the media permission prompt.--use-fake-device-for-media-streamsupplies synthetic audio and video instead of real devices.--incognitoand--user-data-dir=/tmp/xxsgive a clean profile.- The final argument is the page that triggers the crash.
Step 2: observe the crash
The report states that the buffer overflow reproduces immediately. The ASan output begins:
==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x52e0000befe0 at pc 0x653bb5d6c90d bp 0x789085bb7c10 sp 0x789085bb7c08
WRITE of size 4 at 0x52e0000befe0 thread T75 (CodecWorker)
#0 0x653bb5d6c90c in fill_variance ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:103:23
#1 0x653bb5d6c90c in fill_variance_4x4avg ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:420:5
#2 0x653bb5d6c90c in fill_variance_tree_leaves ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1166:13
#3 0x653bb5d6c90c in [redacted] ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1744:3
#4 0x653bb5b05112 in encode_nonrd_sb ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:555:5
#5 0x653bb5b05112 in encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1246:7
#6 0x653bb5b05112 in av1_encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1435:3
#7 0x653bb5bc3223 in enc_row_mt_worker_hook ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:721:5
The stack shows the write happening in fill_variance at var_based_part.c:103, called from the 4x4 average variant and the tree leaf walk, all within the variance based partitioning decision for a superblock. Above that, encode_nonrd_sb and encode_sb_row show this is the non-rd (non rate-distortion optimised) encode path, running on the row-multithreading worker hook enc_row_mt_worker_hook.
Step 3: trace the allocation
The report then shows where the overrun region was allocated:
0x52e0000befe0 is located 313 bytes after 43687-byte region [0x52e0000b4400,0x52e0000beea7)
allocated by thread T2 (ThreadPoolForeg) here:
#0 0x653ba045678f in __interceptor_malloc _asan_rtl_:3
#1 0x653bb5a0cbe9 in aom_memalign ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:59:22
#2 0x653bb5a0cbe9 in aom_malloc ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:67:40
#3 0x653bb5bb3afa in av1_init_tile_thread_data ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:1052:11
#4 0x653bb5a5b47b in encoder_encode ./../../third_party/libaom/source/libaom/av1/av1_cx_iface.c:3233:7
#5 0x653bb5a4b712 in aom_codec_encode ./../../third_party/libaom/source/libaom/aom/src/aom_encoder.c:191:11
#6 0x653bc54d33b2 in webrtc::(anonymous namespace)::LibaomAv1Encoder::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocator<webrtc::VideoFrameType>> const*) ./../../third_party/webrtc/modules/video_coding/codecs/av1/libaom_av1_encoder.cc:700:9
The buffer is allocated by av1_init_tile_thread_data during encoder_encode, reached from WebRTC's LibaomAv1Encoder::Encode. The write that overruns it happens on a different thread, the CodecWorker thread, which is created from the same encode call chain. The report also shows the thread creation stacks: T75 (CodecWorker) is created by T2 (ThreadPoolForeg) through av1_create_workers and CodecWorkerImpl::Reset, and T2 is created by T0 (chrome) as part of the renderer's thread pool startup.
Step 4: read the shadow memory
The ASan report includes the shadow byte map around the faulting address, with the poisoned bytes marked fa (heap left redzone) and the faulting byte bracketed:
=>0x52e0000bef80: fa fa fa fa fa fa fa fa fa fa fa fa[fa]fa fa fa
The summary line identifies the fault as AddressSanitizer: heap-buffer-overflow in the ASan build. The additional info section records the task trace that led to the encode:
Task trace:
#0 0x653ba3057e1a in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::ChangeStateImpl(AVxWorker*, AVxWorkerStatus) ./../../media/base/codec_worker_impl.h:91:11
#1 0x653bb5341bf3 in webrtc::(anonymous namespace)::FrameCadenceAdapterImpl::OnFrame(webrtc::VideoFrame const&) ./../../third_party/webrtc/video/frame_cadence_adapter.cc:951:11
#2 0x653bc587e0a5 in blink::MediaStreamVideoWebRtcSink::WebRtcVideoSourceAdapter::OnVideoFrameOnIO(scoped_refptr<media::VideoFrame>, base::TimeTicks) ./../../third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc:172:46
This ties the encode back to a video frame arriving from a Blink media stream sink, that is, a frame produced for a WebRTC video track.
Root cause
The report identifies the faulting function as fill_variance in av1/encoder/var_based_part.c, writing 4 bytes past the end of a buffer allocated by av1_init_tile_thread_data. The write happens while the encoder computes variance statistics for the leaves of the partition tree of a superblock. The report does not state the exact condition under which the computed index exceeds the allocation, so the precise trigger (frame dimensions, superblock position or thread data sizing) is not documented here.
What the stack does show is that the partitioning decision and the buffer allocation are separated across threads: the buffer is allocated on the renderer thread pool during encoder_encode, and the out-of-bounds write happens later on a CodecWorker thread. ASan caught the write because the bytes past the allocation were redzone, so the overflow was detected at the first write beyond the region rather than being silently absorbed.
Impact
The report describes a heap buffer overflow in WebRTC. The crash is triggered by encoding a video frame through the AV1 encoder during a WebRTC session. The report contains only the crash and its stack traces.
Fix
Variants to test
- Run the same reproduction against other Chromium versions and other libaom based encoders (for example the standalone
aom_codec_encodepath) to see whether the overflow depends on the encoder configuration chosen by WebRTC. A positive result is the samefill_variancewrite past the allocation under ASan. - Vary the synthetic video source resolution and frame rate supplied by
--use-fake-device-for-media-streamand check whether the overflow still occurs. A positive result is the same ASan heap-buffer-overflow invar_based_part.c. - Exercise the non-rd encode path with different speed settings or real-time configurations, since the stack shows
encode_nonrd_sb. A positive result is the same write infill_variancereached through[redacted]. - Test other codec worker paths that allocate per-tile thread data, such as VP8 or VP9 encoders, for similar sizing mistakes between allocation and use. A positive result is an ASan report showing a write past a buffer allocated in the corresponding
*_init_tile_thread_datafunction.
What happened, in plain words
A security researcher found a bug in Google Chrome. When Chrome was sending a video call, a part of the browser that compresses video wrote a few bytes of data past the end of a reserved block of memory. That kind of mistake is called a heap buffer overflow. It was reported to Google's Chrome Vulnerability Rewards Program (VRP), the scheme that pays people for finding and reporting security bugs. The bug was given the tracking number CVE-2024-5493. A CVE is a public catalogue number for a known security flaw, so people can look it up and follow it.
The faulty code lives in libaom, the software library that Chrome uses to encode video in a format called AV1. Encoding means turning raw camera pictures into a compressed stream that can be sent over the network. The crash happened while Chrome was encoding a video stream for a WebRTC session. WebRTC is the technology that lets a web page make audio and video calls directly in the browser, without installing anything.
The specific function that wrote too far is called fill_variance. It is part of the encoder's decision about how to chop each picture into smaller pieces before compressing them. The report shows that this code path can write past the end of a block of memory that was reserved on the heap. The heap is the general-purpose pool of memory a program uses for data it creates while running, as opposed to the small fixed slots it keeps for itself.
Context
This is a Chrome VRP report for a heap buffer overflow in WebRTC, tracked as CVE-2024-5493 and rated high severity. The crash happens inside libaom, the AV1 codec library bundled with Chromium, while the browser is encoding a video stream for a WebRTC session. The faulting write is in the encoder's variance based partitioning code, which decides how a superblock is split into smaller blocks before encoding.
A codec is the piece of software that compresses and decompresses audio or video. AV1 is one particular video codec, and libaom is the library that implements it. A superblock is a square chunk of a video frame, the unit the encoder works on before deciding how to subdivide it. Variance based partitioning means the encoder looks at how much the colours in a block vary, and uses that to decide whether to split the block into smaller pieces. More detail in busy areas, less in flat areas, is the general idea.
In normal use, a page that opens a WebRTC connection with an AV1 video track causes Chrome to feed captured frames into the libaom AV1 encoder. A track is one stream of media, for example the video from your camera. The encoder runs on worker threads, which are separate lines of execution inside the browser that let heavy work happen in the background. For each superblock, the encoder computes variance statistics to choose a partition. The report shows that this path can write past the end of a heap allocation.
Setup
The researcher tested on Ubuntu 22.04, a version of the Linux operating system, with two Chromium builds:
- Chromium 126.0.6461.0
- Chromium 119.0.6041.0
Chromium is the open-source browser project that Chrome is built from. A build is a compiled copy of the program.
The ASan report's summary line shows the binary path /home/pwn11/asan-linux-release/chrome. AddressSanitizer, usually shortened to ASan, is a tool built into a special version of a program that watches memory use and stops the program the moment it touches memory it should not. Think of it as a smoke alarm for memory mistakes: normal builds may keep running quietly after a small overflow, while an ASan build raises the alarm immediately and prints a detailed report. The test page was served locally at http://localhost:8880/crash.html. Serving locally means the page was on the researcher's own machine, not on the internet, and localhost is the name a computer uses for itself.
Finding it
The report does not describe how the researcher arrived at the bug, only the reproduction. What the ASan output shows is a write of size 4 landing 313 bytes after the end of a 43687-byte heap region. A write of size 4 means four bytes were stored at once, roughly the space of a single number. The region is the block of memory that had been reserved, and the write landed outside it.
The write occurs on a CodecWorker thread inside fill_variance, reached through fill_variance_4x4avg, fill_variance_tree_leaves and [redacted]. Those names describe a chain of calls: the top-level partitioning decision calls a function that walks the leaves of a tree of blocks, which calls a version that averages 4x4 pixel groups, which finally calls fill_variance to store the result. The allocation that is overrun comes from av1_init_tile_thread_data, called from encoder_encode while the WebRTC LibaomAv1Encoder is encoding a frame. In plain terms: one part of the encoder reserved a block of memory for its per-thread working data, and a later step wrote just past the end of it.
Exploitation
Step 1: launch Chromium with fake media devices
The reproduction uses a single command line that starts Chromium with a fake camera and microphone, so no real capture device is needed, and points it at the local test page:
./chrome --disable-gpu --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --incognito --user-data-dir=/tmp/xxs http://localhost:8880/crash.html
Line by line:
./chromeruns the Chromium program sitting in the current folder. The./simply means "in this folder".--disable-gputurns off graphics-card acceleration, so the browser does the video work in ordinary software.--use-fake-ui-for-media-streammakes the browser automatically accept the pop-up that normally asks permission to use the camera and microphone. Without it, a human would have to click Allow every time.--use-fake-device-for-media-streamgives the browser a synthetic camera and microphone instead of real hardware. The browser then produces test video and audio by itself, so the test works on any computer, even one with no webcam.--incognitoopens a private browsing window, which starts without saved history or logins.--user-data-dir=/tmp/xxstells the browser to keep its profile data in a fresh folder,/tmp/xxs, so the test does not touch the normal profile./tmpis a temporary folder on Linux.- The final argument,
http://localhost:8880/crash.html, is the page that triggers the crash. It is served from the researcher's own machine on port 8880.
Step 2: observe the crash
The report states that the buffer overflow reproduces immediately. The ASan output begins:
==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x52e0000befe0 at pc 0x653bb5d6c90d bp 0x789085bb7c10 sp 0x653bb5d6c90c
WRITE of size 4 at 0x52e0000befe0 thread T75 (CodecWorker)
#0 0x653bb5d6c90c in fill_variance ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:103:23
#1 0x653bb5d6c90c in fill_variance_4x4avg ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:420:5
#2 0x653bb5d6c90c in fill_variance_tree_leaves ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1166:13
#3 0x653bb5d6c90c in [redacted] ./../../third_party/libaom/source/libaom/av1/encoder/var_based_part.c:1744:3
#4 0x653bb5b05112 in encode_nonrd_sb ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:555:5
#5 0x653bb5b05112 in encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1246:7
#6 0x653bb5b05112 in av1_encode_sb_row ./../../third_party/libaom/source/libaom/av1/encoder/encodeframe.c:1435:3
#7 0x653bb5bc3223 in enc_row_mt_worker_hook ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:721:5
This is a stack trace. A stack trace is the list of function calls that led to the moment of the crash, with the most recent call at the top. Reading it from top to bottom tells you what happened and who called it.
- The first line is the alarm itself: AddressSanitizer reports a heap-buffer-overflow at a particular memory address. The long numbers are memory addresses, the equivalent of house numbers for bytes in memory.
WRITE of size 4says four bytes were being stored when the alarm went off, on a thread namedT75 (CodecWorker). A thread is one line of work inside a program; the browser uses several at once so it can keep working while heavy tasks run.#0is the innermost function,fill_variance, in the filevar_based_part.cat line 103. This is where the illegal write happened.#1to#3show the chain of calls inside the same file: the 4x4 average variant, the tree leaf walk, and the top-level variance based partitioning decision.#4to#6show the encoder's frame loop:encode_nonrd_sbandencode_sb_rowmean this is the non-rd (non rate-distortion optimised) encode path, a faster mode used for real-time video. Rate-distortion optimisation is a slower, more careful way of choosing how to encode; the non-rd path skips some of that care for speed.#7,enc_row_mt_worker_hook, is the worker routine that processes rows of the frame in parallel, which is why this work is happening on a background thread.
Step 3: trace the allocation
The report then shows where the overrun region was allocated:
0x52e0000befe0 is located 313 bytes after 43687-byte region [0x52e0000b4400,0x52e0000beea7)
allocated by thread T2 (ThreadPoolForeg) here:
#0 0x653ba045678f in __interceptor_malloc _asan_rtl_:3
#1 0x653bb5a0cbe9 in aom_memalign ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:59:22
#2 0x653bb5a0cbe9 in aom_malloc ./../../third_party/libaom/source/libaom/aom_mem/aom_mem.c:67:40
#3 0x653bb5bb3afa in av1_init_tile_thread_data ./../../third_party/libaom/source/libaom/av1/encoder/ethread.c:1052:11
#4 0x653bb5a5b47b in encoder_encode ./../../third_party/libaom/source/libaom/av1/av1_cx_iface.c:3233:7
#5 0x653bb5a4b712 in aom_codec_encode ./../../third_party/libaom/source/libaom/aom/src/aom_encoder.c:191:11
#6 0x653bc54d33b2 in webrtc::(anonymous namespace)::LibaomAv1Encoder::Encode(webrtc::VideoFrame const&, std::__Cr::vector<webrtc::VideoFrameType, std::__Cr::allocator<webrtc::VideoFrameType>> const*) ./../../third_party/webrtc/modules/video_coding/codecs/av1/libaom_av1_encoder.cc:700:9
This second stack trace answers a different question: not "where did the crash happen" but "who reserved the memory that was overrun".
- The first line says the bad address sits 313 bytes after a region of 43687 bytes. The two addresses in square brackets are the start and end of that region.
allocated by thread T2 (ThreadPoolForeg)says a different thread, one from the browser's general-purpose thread pool, reserved the block. A thread pool is a set of reusable worker threads the browser keeps around for background jobs.#0shows the actual memory reservation going throughmalloc, the standard C function for asking the operating system for memory. The__interceptor_mallocname is ASan's wrapper around it, which lets ASan record every allocation.#1and#2,aom_memalignandaom_malloc, are libaom's own wrappers aroundmalloc.#3,av1_init_tile_thread_data, is the function that set up per-thread working data for encoding a tile. A tile is a rectangular slice of a frame that can be encoded in parallel.#4and#5,encoder_encodeandaom_codec_encode, are the encoder's main entry points.#6,LibaomAv1Encoder::Encode, is WebRTC's wrapper that hands a video frame to libaom.
The buffer is allocated by av1_init_tile_thread_data during encoder_encode, reached from WebRTC's LibaomAv1Encoder::Encode. The write that overruns it happens on a different thread, the CodecWorker thread, which is created from the same encode call chain. The report also shows the thread creation stacks: T75 (CodecWorker) is created by T2 (ThreadPoolForeg) through av1_create_workers and CodecWorkerImpl::Reset, and T2 is created by T0 (chrome) as part of the renderer's thread pool startup. In other words, the memory was reserved on one thread and misused on another, which is a common pattern in multithreaded code and one reason these bugs can be hard to spot by reading the code alone.
Step 4: read the shadow memory
The ASan report includes the shadow byte map around the faulting address, with the poisoned bytes marked fa (heap left redzone) and the faulting byte bracketed:
=>0x52e0000bef80: fa fa fa fa fa fa fa fa fa fa fa fa[fa]fa fa fa
Shadow memory is ASan's bookkeeping: for every eight bytes of real memory, it keeps one extra byte saying whether those eight bytes are safe to use. The legend in the full report explains the codes. fa means a redzone, a deliberately unused strip of memory placed around each allocation so that a small overflow lands somewhere ASan is watching. The arrow => points at the row containing the faulting address, and the bracketed [fa] is the exact byte that was touched. Seeing fa there confirms the write went into the redzone just past the end of the real block.
The summary line identifies the fault as AddressSanitizer: heap-buffer-overflow in the ASan build. The additional info section records the task trace that led to the encode:
Task trace:
#0 0x653ba3057e1a in media::CodecWorkerImpl<AVxWorkerInterface, AVxWorkerImpl, AVxWorker, AVxWorkerStatus, (AVxWorkerStatus)0, (AVxWorkerStatus)1, (AVxWorkerStatus)2>::ChangeStateImpl(AVxWorker*, AVxWorkerStatus) ./../../media/base/codec_worker_impl.h:91:11
#1 0x653bb5341bf3 in webrtc::(anonymous namespace)::FrameCadenceAdapterImpl::OnFrame(webrtc::VideoFrame const&) ./../../third_party/webrtc/video/frame_cadence_adapter.cc:951:11
#2 0x653bc587e0a5 in blink::MediaStreamVideoWebRtcSink::WebRtcVideoSourceAdapter::OnVideoFrameOnIO(scoped_refptr<media::VideoFrame>, base::TimeTicks) ./../../third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc:172:46
This ties the encode back to a video frame arriving from a Blink media stream sink, that is, a frame produced for a WebRTC video track. Blink is the part of Chrome that renders web pages and runs their JavaScript. A sink, in this context, is the place where a stream of frames ends up. Reading the trace from the bottom up: a frame arrives from the media stream, the frame cadence adapter (which controls how often frames are passed on) hands it over, and the codec worker is asked to change state and start encoding.
Root cause
The report identifies the faulting function as fill_variance in av1/encoder/var_based_part.c, writing 4 bytes past the end of a buffer allocated by av1_init_tile_thread_data. The write happens while the encoder computes variance statistics for the leaves of the partition tree of a superblock. The report does not state the exact condition under which the computed index exceeds the allocation, so the precise trigger (frame dimensions, superblock position or thread data sizing) is not documented here.
What the stack does show is that the partitioning decision and the buffer allocation are separated across threads: the buffer is allocated on the renderer thread pool during encoder_encode, and the out-of-bounds write happens later on a CodecWorker thread. ASan caught the write because the bytes past the allocation were redzone, so the overflow was detected at the first write beyond the region rather than being silently absorbed. ASan caught the write because the bytes past the allocation were redzone.
Impact
The report describes a heap buffer overflow in WebRTC. The crash is triggered by encoding a video frame through the AV1 encoder during a WebRTC session. The report contains only the crash and its stack traces.
Fix
Variants to test
- Run the same reproduction against other Chromium versions and other libaom based encoders (for example the standalone
aom_codec_encodepath) to see whether the overflow depends on the encoder configuration chosen by WebRTC. A positive result is the samefill_variancewrite past the allocation under ASan. - Vary the synthetic video source resolution and frame rate supplied by
--use-fake-device-for-media-streamand check whether the overflow still occurs. A positive result is the same ASan heap-buffer-overflow invar_based_part.c. - Exercise the non-rd encode path with different speed settings or real-time configurations, since the stack shows
encode_nonrd_sb. A positive result is the same write infill_variancereached through[redacted]. - Test other codec worker paths that allocate per-tile thread data, such as VP8 or VP9 encoders, for similar sizing mistakes between allocation and use. A positive result is an ASan report showing a write past a buffer allocated in the corresponding
*_init_tile_thread_datafunction.
Glossary
- AddressSanitizer (ASan): a tool built into a special version of a program that watches memory use and stops the program the moment it touches memory it should not.
- Allocation: a block of memory reserved for a program to use.
- AV1: a video compression format, implemented by the libaom library.
- Blink: the part of Chrome that renders web pages and runs their JavaScript.
- Buffer: a block of memory used to hold data, here the working data for encoding.
- Build: a compiled copy of a program.
- Chromium: the open-source browser project that Chrome is built from.
- Codec: software that compresses and decompresses audio or video.
- CVE: a public catalogue number for a known security flaw.
- Heap: the general-purpose pool of memory a program uses for data it creates while running.
- Heap buffer overflow: writing data past the end of a block of memory reserved on the heap.
- libaom: the library that implements the AV1 video codec.
- localhost: the name a computer uses to refer to itself.
- malloc: the standard C function for asking the operating system for memory.
- Non-rd (non rate-distortion optimised): a faster encoding mode that skips some of the careful analysis used for the best possible quality.
- Partition: the way the encoder splits a block of a frame into smaller blocks.
- Redzone: a deliberately unused strip of memory placed around each allocation so that small overflows land somewhere ASan is watching.
- Renderer: the part of the browser that draws pages and runs their code.
- Shadow memory: ASan's bookkeeping that records, for every eight bytes of real memory, whether those bytes are safe to use.
- Stack trace: the list of function calls that led to a moment in a program, most recent first.
- Superblock: a square chunk of a video frame that the encoder works on before deciding how to subdivide it.
- Thread: one line of work inside a program; a program can run several at once.
- Thread pool: a set of reusable worker threads kept around for background jobs.
- Tile: a rectangular slice of a frame that can be encoded in parallel.
- Track: one stream of media, for example the video from a camera.
- Variance based partitioning: choosing how to split a block based on how much the colours in it vary.
- VRP (Vulnerability Rewards Program): a scheme that pays people for finding and reporting security bugs.
- WebRTC: the technology that lets a web page make audio and video calls directly in the browser.
- Worker thread: a background thread that performs heavy work so the main program stays responsive.