Skip to content
Memory corruption Advisory Advanced CVE-2026-10903

Use after free in WebRTC (CVE-2026-10903)

A use-after-free exists in WebRTC's SCTP data channel code: when a DCEP OPEN message exceeds the negotiated max-message-size, sending it fails and destroys the channel while the caller still holds a raw pointer to it. A web page can trigger this deterministically by creating data channels with long labels and editing the remote SDP to set a tiny max-message-size, crashing the renderer.

c6eed09fc8b174b0f3eebedcceb1e792 Follow

Originally disclosed on Chrome VRP

Bounty$11,000 High View original
  • Fix shipped in 47 days

Use-After-Free in AllocateSctpSids via DCEP OPEN Message Failure Leads to Renderer Crash

Summary

A use-after-free vulnerability exists in the WebRTC SCTP data channel implementation. When DataChannelController::AllocateSctpSids iterates over newly assigned channels using raw pointers, the act of sending the DCEP OPEN control message can synchronously fail if the message exceeds the negotiated max-message-size. The failure path destroys the SctpDataChannel object while the calling function still holds and uses the now-dangling raw pointer. A web page can trigger this deterministically, without any race condition, by creating data channels with long labels and then munging the remote SDP to set an artificially small max-message-size. The bug affects all platforms. MiraclePtr does not protect this code path.

Bisect

Introducing Commit: 1fbc1f1be61c6ad0ee5212b5e29ebc4103e8b8eb

Root Cause

DataChannelController::AllocateSctpSids assigns stream IDs to pending data channels and then starts them. The function collects channels into a local vector of raw pointers before calling OnTransportReady on each one:

C++
// third_party/webrtc/pc/data_channel_controller.cc:455-488
void DataChannelController::AllocateSctpSids(SSLRole role) {
  std::vector<SctpDataChannel*> channels_to_start;
  // ...
  for (auto it = sctp_data_channels_n_.begin();
       it != sctp_data_channels_n_.end();) {
    if (!(*it)->sid_n().has_value()) {
      std::optional<StreamId> sid = sid_allocator_.AllocateSid(role);
      if (sid.has_value()) {
        (*it)->SetSctpSid_n(*sid);
        AddSctpDataStream(*sid, (*it)->priority());
        channels_to_start.push_back((*it).get());  // raw pointer extracted
      }
      // ...
    }
    ++it;
  }
  if (ready_to_send) {
    for (auto* channel : channels_to_start) {
      channel->OnTransportReady();  // uses raw pointer after potential free
    }
  }
}

A comment in the code acknowledges that "OnTransportReady can cause sending, and sending may fail and cause channel to close," yet the function stores only raw pointers rather than scoped_refptr to keep the channels alive.

OnTransportReady delegates to UpdateState, which, for channels in the kConnecting state with handshake_state_ equal to kHandshakeShouldSendOpen, serializes a DCEP OPEN message and passes it to SendControlMessage:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:791-822
void SctpDataChannel::UpdateState() {
  switch (state_) {
    case kConnecting: {
      if (connected_to_transport() && controller_) {
        if (handshake_state_ == kHandshakeShouldSendOpen) {
          CopyOnWriteBuffer payload;
          WriteDataChannelOpenMessage(label_, protocol_, priority_, ordered_,
                                      max_retransmits_, max_retransmit_time_,
                                      &payload);
          SendControlMessage(payload);
        }
        // ... execution continues here after SendControlMessage returns
        if (handshake_state_ == kHandshakeReady ||
            handshake_state_ == kHandshakeWaitingForAck) {
          SetState(kOpen);
        }
      }
      break;
    }
    case kOpen: {  // line 823: the UAF read occurs here
      break;
    }
    // ...
  }
}

SendControlMessage calls controller_->SendData, which routes through DcSctpTransport::SendData. That function enforces the negotiated max-message-size:

C++
// third_party/webrtc/media/sctp/dcsctp_transport.cc:341-348
auto max_message_size = socket_->options().max_message_size;
if (max_message_size > 0 && payload.size() > max_message_size) {
  return RTCError(RTCErrorType::INVALID_RANGE);
}

When the DCEP OPEN message (12 bytes of header plus the label and protocol strings) exceeds this limit, SendData returns an INVALID_RANGE error. SendControlMessage then calls CloseAbruptlyWithError:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:970-1003
bool SctpDataChannel::SendControlMessage(const CopyOnWriteBuffer& buffer) {
  RTCError err = controller_->SendData(*id_n_, send_params, buffer);
  if (!err.ok()) {
    CloseAbruptlyWithError(err);
  }
  return err.ok();
}

CloseAbruptlyWithError transitions the channel through kClosing to kClosed via SetState. Each SetState call notifies the controller through OnChannelStateChanged:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:853-865
void SctpDataChannel::SetState(DataState state) {
  state_ = state;
  if (observer_)
    observer_->OnStateChange();
  if (controller_)
    controller_->OnChannelStateChanged(this, state_);
}

When the state reaches kClosed, OnChannelStateChanged calls OnSctpDataChannelClosed, which erases the channel from the controller's sctp_data_channels_n_ vector:

C++
// third_party/webrtc/pc/data_channel_controller.cc:110-119
void DataChannelController::OnChannelStateChanged(
    SctpDataChannel* channel,
    DataChannelInterface::DataState state) {
  if (state == DataChannelInterface::DataState::kClosed)
    OnSctpDataChannelClosed(channel);
  // ...
}

// third_party/webrtc/pc/data_channel_controller.cc:497-508
void DataChannelController::OnSctpDataChannelClosed(SctpDataChannel* channel) {
  auto it = absl::c_find_if(sctp_data_channels_n_,
                            [&](const auto& c) { return c.get() == channel; });
  if (it != sctp_data_channels_n_.end()) {
    sctp_data_channels_n_.erase(it);  // drops the scoped_refptr
  }
}

If the JavaScript page does not retain a reference to the RTCDataChannel wrapper, the scoped_refptr in sctp_data_channels_n_ is the last reference. Erasing it destroys the SctpDataChannel object. Control then unwinds back through CloseAbruptlyWithError, SendControlMessage, and into UpdateState, which proceeds to evaluate the switch statement against state_, now reading freed memory at offset 232 within the deallocated 312-byte region.

The attacker controls both the label length (which determines the DCEP OPEN message size) and the remote SDP (which sets max-message-size through the a=max-message-size attribute). By creating data channels with labels of approximately 2000 bytes and munging the answer SDP to set max-message-size to 10, the DCEP OPEN message of roughly 2012 bytes is guaranteed to exceed the limit. The bug is fully deterministic and requires no race condition or timing sensitivity.

Reproduce

Tested at commit bb43679d94d13.

Build with ASAN:

autoninja -C ~/chromium/src/out/asan-release chrome

Launch:

ASAN_OPTIONS=detect_odr_violation=0 ~/chromium/src/out/asan-release/chrome \
  --no-sandbox --disable-gpu \
  --js-flags="--expose-gc" \
  --user-data-dir=/tmp/poc-$(date +%s) \
  ~/chromium/src/issue_webrtc032/poc.html

The renderer process crashes with a heap-use-after-free within seconds of the SCTP association establishing. No user interaction is required.

==2497007==ERROR: AddressSanitizer: heap-use-after-free on address 0x7c1bb8d10ba8 at pc 0x7efc2bf06be6 bp 0x7afaac6c5370 sp 0x7afaac6c5368
READ of size 4 at 0x7c1bb8d10ba8 thread T12 (WebRTC_W_and_N)
    #0 0x7efc2bf06be5 in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:823:13
    #1 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16
    #2 0x7efc2bcb241f in non-virtual thunk to webrtc::DcSctpTransport::OnConnected() third_party/webrtc/media/sctp/dcsctp_transport.cc:581:25
    #3 0x7efc2bcb6866 in dcsctp::CallbackDeferrer::TriggerDeferred() third_party/webrtc/net/dcsctp/socket/callback_deferrer.cc:49:5
    #4 0x7efc2bcc5122 in dcsctp::DcSctpSocket::ReceivePacket(std::__Cr::span<unsigned char const, 18446744073709551615ul>) third_party/webrtc/net/dcsctp/socket/callback_deferrer.h:54:44
    #5 0x7efc2bae945a in webrtc::callback_list_impl::CallbackListReceivers::Foreach(webrtc::FunctionView<void (webrtc::UntypedFunction&)>) third_party/webrtc/api/function_view.h:96:12
    #6 0x7efc2b9c2f29 in webrtc::PacketTransportInternal::NotifyPacketReceived(webrtc::ReceivedIpPacket const&) third_party/webrtc/rtc_base/callback_list.h:211:16
    #7 0x7efc2be0ec0c in webrtc::DtlsTransportInternalImpl::OnDtlsEvent(int, int) third_party/webrtc/p2p/dtls/dtls_transport.cc:1019:9
    #8 0x7efc2be03b93 in webrtc::StreamInterfaceChannel::OnPacketReceived(std::__Cr::span<unsigned char const, 18446744073709551615ul>) third_party/abseil-cpp/absl/functional/internal/any_invocable.h:766:1
    #9 0x7efc2be0dad8 in webrtc::DtlsTransportInternalImpl::OnReadPacket(webrtc::PacketTransportInternal*, webrtc::ReceivedIpPacket const&, bool) third_party/webrtc/p2p/dtls/dtls_transport.cc:1114:21
    #10 0x7efc2bae945a in webrtc::callback_list_impl::CallbackListReceivers::Foreach(webrtc::FunctionView<void (webrtc::UntypedFunction&)>) third_party/webrtc/api/function_view.h:96:12
    #11 0x7efc2b9c2f29 in webrtc::PacketTransportInternal::NotifyPacketReceived(webrtc::ReceivedIpPacket const&) third_party/webrtc/rtc_base/callback_list.h:211:16
    #12 0x7efc2b9c0f00 in void absl::internal_any_invocable::LocalInvoker<false, void, webrtc::P2PTransportChannel::AddConnection(webrtc::Connection*)::$_0&, webrtc::Connection*, webrtc::ReceivedIpPacket const&>(absl::internal_any_invocable::TypeErasedState*, absl::internal_any_invocable::ForwardedParameter<webrtc::Connection*>::type, absl::internal_any_invocable::ForwardedParameter<webrtc::ReceivedIpPacket const&>::type) third_party/webrtc/p2p/base/p2p_transport_channel.cc:2270:3
    #13 0x7efc2b98985e in webrtc::Connection::OnReadPacket(webrtc::ReceivedIpPacket const&) third_party/abseil-cpp/absl/functional/internal/any_invocable.h:766:1
    #14 0x7efc2c0124a8 in webrtc::UDPPort::HandleIncomingPacket(webrtc::AsyncPacketSocket*, webrtc::ReceivedIpPacket const&) third_party/webrtc/p2p/base/stun_port.cc:363:3
    #15 0x7efbde87d286 in blink::(anonymous namespace)::IpcPacketSocket::OnDataReceived(net::IPEndPoint const&, base::span<unsigned char const, 18446744073709551615ul, unsigned char const*>, base::TimeTicks const&, webrtc::EcnMarking) third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc:709:3
    #16 0x7efbde88a16a in non-virtual thunk to blink::P2PSocketClientImpl::DataReceived(blink::Vector<mojo::StructPtr<network::mojom::blink::P2PReceivedPacket>, 0u, blink::PartitionAllocator>) third_party/blink/renderer/platform/p2p/socket_client_impl.cc:187:18
    #17 0x7efbdf6d7770 in network::mojom::blink::P2PSocketClientStubDispatch::Accept(network::mojom::blink::P2PSocketClient*, mojo::Message*) gen/services/network/public/mojom/p2p.mojom-blink.cc:2039:13
    #18 0x7efc3e0f2062 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:1085:54
    #19 0x7efc3e10942b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19
    #20 0x7efc3e0f7914 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:747:20
    #21 0x7efc3e118a0e in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) mojo/public/cpp/bindings/lib/multiplex_router.cc:1204:42
    #22 0x7efc3e11723d in mojo::internal::MultiplexRouter::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/multiplex_router.cc:790:7
    #23 0x7efc3e10942b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19
    #24 0x7efc3e0ddc8f in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>) mojo/public/cpp/bindings/lib/connector.cc:567:49
    #25 0x7efc3e0df4de in mojo::Connector::ReadAllAvailableMessages() mojo/public/cpp/bindings/lib/connector.cc:628:14
    #26 0x7efc3e0e0404 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::*&&)(), base::WeakPtr<mojo::Connector>&&>, base::internal::BindState<true, true, false, void (mojo::Connector::*)(), base::WeakPtr<mojo::Connector>>, void ()>::RunOnce(base::internal::BindStateBase*) base/functional/bind_internal.h:740:12
    #27 0x7efc3cb61b59 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) base/functional/callback.h:155:12
    #28 0x7efc3cbdc1d0 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) base/task/common/task_annotator.h:112:5
    #29 0x7efc3cbdb1a6 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:336:40
    #30 0x7efc3ca02e24 in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) base/message_loop/message_pump_default.cc:42:55
    #31 0x7efc3cbdd823 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:640:12
    #32 0x7efc3caccc72 in base::RunLoop::Run(base::Location const&) base/run_loop.cc:135:14
    #33 0x7efc3cc75892 in base::Thread::Run(base::RunLoop*) base/threading/thread.cc:356:13
    #34 0x7efc3cc75df5 in base::Thread::ThreadMain() base/threading/thread.cc:426:3
    #35 0x7efc3ccdaa4c in base::(anonymous namespace)::ThreadFunc(void*) base/threading/platform_thread_posix.cc:102:13
    #36 0x55a454fd0b36 in asan_thread_start(void*) asan_interceptors.cpp

0x7c1bb8d10ba8 is located 232 bytes inside of 312-byte region [0x7c1bb8d10ac0,0x7c1bb8d10bf8)
freed by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500cdc2 in operator delete(void*, unsigned long) (out/asan-release/chrome+0x681cdc2) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf0e39c in webrtc::RefCountedObject<webrtc::SctpDataChannel>::Release() const third_party/webrtc/rtc_base/ref_counted_object.h:42:7
    #2 0x7efc2bdbb4bb in webrtc::DataChannelController::OnSctpDataChannelClosed(webrtc::SctpDataChannel*) third_party/webrtc/api/scoped_refptr.h:105:13
    #3 0x7efc2bdbaf32 in webrtc::DataChannelController::OnChannelStateChanged(webrtc::SctpDataChannel*, webrtc::DataChannelInterface::DataState) third_party/webrtc/pc/data_channel_controller.cc:119:5
    #4 0x7efc2bf0b244 in webrtc::SctpDataChannel::SendControlMessage(webrtc::CopyOnWriteBuffer const&) third_party/webrtc/pc/sctp_data_channel.cc:1013:5
    #5 0x7efc2bf0655c in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:817:11
    #6 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16
    #7 0x7efc2bcb241f in non-virtual thunk to webrtc::DcSctpTransport::OnConnected() third_party/webrtc/media/sctp/dcsctp_transport.cc:581:25
    #8 0x7efc2bcb6866 in dcsctp::CallbackDeferrer::TriggerDeferred() third_party/webrtc/net/dcsctp/socket/callback_deferrer.cc:49:5
    #9 0x7efc2bcc5122 in dcsctp::DcSctpSocket::ReceivePacket(std::__Cr::span<unsigned char const, 18446744073709551615ul>) third_party/webrtc/net/dcsctp/socket/callback_deferrer.h:54:44
    #10 0x7efc2bae945a in webrtc::callback_list_impl::CallbackListReceivers::Foreach(webrtc::FunctionView<void (webrtc::UntypedFunction&)>) third_party/webrtc/api/function_view.h:96:12
    #11 0x7efc2b9c2f29 in webrtc::PacketTransportInternal::NotifyPacketReceived(webrtc::ReceivedIpPacket const&) third_party/webrtc/rtc_base/callback_list.h:211:16
    #12 0x7efc2be0ec0c in webrtc::DtlsTransportInternalImpl::OnDtlsEvent(int, int) third_party/webrtc/p2p/dtls/dtls_transport.cc:1019:9
    #13 0x7efc2be03b93 in webrtc::StreamInterfaceChannel::OnPacketReceived(std::__Cr::span<unsigned char const, 18446744073709551615ul>) third_party/abseil-cpp/absl/functional/internal/any_invocable.h:766:1
    #14 0x7efc2be0dad8 in webrtc::DtlsTransportInternalImpl::OnReadPacket(webrtc::PacketTransportInternal*, webrtc::ReceivedIpPacket const&, bool) third_party/webrtc/p2p/dtls/dtls_transport.cc:1114:21
    #15 0x7efc2bae945a in webrtc::callback_list_impl::CallbackListReceivers::Foreach(webrtc::FunctionView<void (webrtc::UntypedFunction&)>) third_party/webrtc/api/function_view.h:96:12
    #16 0x7efc2b9c2f29 in webrtc::PacketTransportInternal::NotifyPacketReceived(webrtc::ReceivedIpPacket const&) third_party/webrtc/rtc_base/callback_list.h:211:16
    #17 0x7efc2b9c0f00 in void absl::internal_any_invocable::LocalInvoker<false, void, webrtc::P2PTransportChannel::AddConnection(webrtc::Connection*)::$_0&, webrtc::Connection*, webrtc::ReceivedIpPacket const&>(absl::internal_any_invocable::TypeErasedState*, absl::internal_any_invocable::ForwardedParameter<webrtc::Connection*>::type, absl::internal_any_invocable::ForwardedParameter<webrtc::ReceivedIpPacket const&>::type) third_party/webrtc/p2p/base/p2p_transport_channel.cc:2270:3
    #18 0x7efc2b98985e in webrtc::Connection::OnReadPacket(webrtc::ReceivedIpPacket const&) third_party/abseil-cpp/absl/functional/internal/any_invocable.h:766:1
    #19 0x7efc2c0124a8 in webrtc::UDPPort::HandleIncomingPacket(webrtc::AsyncPacketSocket*, webrtc::ReceivedIpPacket const&) third_party/webrtc/p2p/base/stun_port.cc:363:3
    #20 0x7efbde87d286 in blink::(anonymous namespace)::IpcPacketSocket::OnDataReceived(net::IPEndPoint const&, base::span<unsigned char const, 18446744073709551615ul, unsigned char const*>, base::TimeTicks const&, webrtc::EcnMarking) third_party/blink/renderer/platform/p2p/ipc_socket_factory.cc:709:3
    #21 0x7efbde88a16a in non-virtual thunk to blink::P2PSocketClientImpl::DataReceived(blink::Vector<mojo::StructPtr<network::mojom::blink::P2PReceivedPacket>, 0u, blink::PartitionAllocator>) third_party/blink/renderer/platform/p2p/socket_client_impl.cc:187:18
    #22 0x7efbdf6d7770 in network::mojom::blink::P2PSocketClientStubDispatch::Accept(network::mojom::blink::P2PSocketClient*, mojo::Message*) gen/services/network/public/mojom/p2p.mojom-blink.cc:2039:13
    #23 0x7efc3e0f2062 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:1085:54
    #24 0x7efc3e10942b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19
    #25 0x7efc3e0f7914 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:747:20
    #26 0x7efc3e118a0e in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) mojo/public/cpp/bindings/lib/multiplex_router.cc:1204:42
    #27 0x7efc3e11723d in mojo::internal::MultiplexRouter::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/multiplex_router.cc:790:7
    #28 0x7efc3e10942b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19
    #29 0x7efc3e0ddc8f in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>) mojo/public/cpp/bindings/lib/connector.cc:567:49

previously allocated by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500c1bd in operator new(unsigned long) (out/asan-release/chrome+0x681c1bd) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf04232 in webrtc::SctpDataChannel::Create(webrtc::WeakPtr<webrtc::SctpDataChannelControllerInterface>, std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, bool, webrtc::InternalDataChannelInit const&, webrtc::Thread*, webrtc::Thread*) third_party/webrtc/api/make_ref_counted.h:90:27
    #2 0x7efc2bdbf7c9 in webrtc::DataChannelController::CreateDataChannel(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, webrtc::InternalDataChannelInit&) third_party/webrtc/pc/data_channel_controller.cc:409:44
    #3 0x7efc2bdc5081 in void webrtc::FunctionView<void ()>::CallVoidPtr<webrtc::RTCErrorOr<webrtc::scoped_refptr<webrtc::SctpDataChannel>> webrtc::Thread::BlockingCall<webrtc::DataChannelController::InternalCreateDataChannelWithProxy(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, webrtc::InternalDataChannelInit const&)::$_0, webrtc::RTCErrorOr<webrtc::scoped_refptr<webrtc::SctpDataChannel>>, void>(webrtc::DataChannelController::InternalCreateDataChannelWithProxy(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, webrtc::InternalDataChannelInit const&)::$_0&&, base::Location const&)::'lambda'()>(webrtc::FunctionView<void ()>::VoidUnion) third_party/webrtc/pc/data_channel_controller.cc:444:24
    #4 0x7efbd14258e4 in webrtc::ThreadWrapper::ProcessPendingSends() third_party/webrtc/api/function_view.h:96:12
    #5 0x7efbd1428314 in base::internal::Invoker<base::internal::FunctorTraits<void (webrtc::ThreadWrapper::*&&)(), base::WeakPtr<webrtc::ThreadWrapper>&&>, base::internal::BindState<true, true, false, void (webrtc::ThreadWrapper::*)(), base::WeakPtr<webrtc::ThreadWrapper>>, void ()>::RunOnce(base::internal::BindStateBase*) base/functional/bind_internal.h:740:12
    #6 0x7efc3cb61b59 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) base/functional/callback.h:155:12
    #7 0x7efc3cbdc1d0 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) base/task/common/task_annotator.h:112:5
    #8 0x7efc3cbdb1a6 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:336:40
    #9 0x7efc3ca02e24 in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) base/message_loop/message_pump_default.cc:42:55
    #10 0x7efc3cbdd823 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:640:12
    #11 0x7efc3caccc72 in base::RunLoop::Run(base::Location const&) base/run_loop.cc:135:14
    #12 0x7efc3cc75892 in base::Thread::Run(base::RunLoop*) base/threading/thread.cc:356:13
    #13 0x7efc3cc75df5 in base::Thread::ThreadMain() base/threading/thread.cc:426:3
    #14 0x7efc3ccdaa4c in base::(anonymous namespace)::ThreadFunc(void*) base/threading/platform_thread_posix.cc:102:13
    #15 0x55a454fd0b36 in asan_thread_start(void*) asan_interceptors.cpp

SUMMARY: AddressSanitizer: heap-use-after-free third_party/webrtc/pc/sctp_data_channel.cc:823:13 in webrtc::SctpDataChannel::UpdateState()
Shadow bytes around the buggy address:
  0x7c1bb8d10900: fa fa fa fa fa fa f7 fa f7 00 00 00 00 00 00 00
  0x7c1bb8d10980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7c1bb8d10a00: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
  0x7c1bb8d10a80: fa fa fa fa fa fa f7 fa fd fd fd fd fd fd fd fd
  0x7c1bb8d10b00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x7c1bb8d10b80: fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fa
  0x7c1bb8d10c00: fa fa fa fa fa fa f7 fa 00 00 00 00 00 00 00 01
  0x7c1bb8d10c80: fc 00 00 00 00 00 00 00 00 00 01 fc 00 00 00 00
  0x7c1bb8d10d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
  0x7c1bb8d10d80: fa fa fa fa fa fa f7 fa 00 00 00 00 00 00 00 01
  0x7c1bb8d10e00: fc 00 00 00 00 00 00 00 00 00 01 fc 00 00 00 00
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

==2497007==ADDITIONAL INFO

==2497007==Note: Please include this section with the ASan report.
Task trace:
    #0 0x7efc3e0dff96 in mojo::Connector::ScheduleDispatchOfPendingMessagesOrWaitForMore(unsigned long) mojo/public/cpp/bindings/lib/connector.cc:588:7
    #1 0x7efc3e0dff96 in mojo::Connector::ScheduleDispatchOfPendingMessagesOrWaitForMore(unsigned long) mojo/public/cpp/bindings/lib/connector.cc:588:7
    #2 0x7efc3e0dff96 in mojo::Connector::ScheduleDispatchOfPendingMessagesOrWaitForMore(unsigned long) mojo/public/cpp/bindings/lib/connector.cc:588:7
    #3 0x7efc3e0dff96 in mojo::Connector::ScheduleDispatchOfPendingMessagesOrWaitForMore(unsigned long) mojo/public/cpp/bindings/lib/connector.cc:588:7

MiraclePtr Status: NOT PROTECTED
No raw_ptr<T> access to this region was detected prior to this crash.
This crash is still exploitable with MiraclePtr.
Refer to https://chromium.googlesource.com/chromium/src/+/main/base/memory/raw_ptr.md for details.

==2497007==END OF ADDITIONAL INFO

==2497007==ABORTING

References

Credit

Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

WebRTC data channels let a web page open a peer-to-peer byte stream over an SCTP association carried inside DTLS. The browser side of that machinery lives in third_party/webrtc/pc/: DataChannelController owns the set of SctpDataChannel objects, allocates stream IDs once the transport is ready, and drives each channel through its handshake. The handshake itself is the DCEP (Data Channel Establishment Protocol) OPEN message, a small control frame containing the channel label, protocol, priority and reliability parameters.

This report describes a use-after-free in that handshake path. DataChannelController::AllocateSctpSids collects the channels it is about to start in a vector of raw pointers, then calls OnTransportReady on each. Sending the DCEP OPEN message can fail synchronously, and the failure path destroys the channel while the caller still holds the dangling pointer. A page can trigger it deterministically, with no race condition, by combining long channel labels with a manipulated remote SDP. The bug affects all platforms, and MiraclePtr does not protect this code path.

Setup

The issue was reproduced at commit bb43679d94d13. The introducing commit is [redacted], dated 2025-12-22, authored by Harald Alvestrand, reviewed at https://webrtc-review.googlesource.com/c/src/+/435520.

The build is an ASAN release build of Chrome:

Bash
autoninja -C ~/chromium/src/out/asan-release chrome

Chrome is launched against a local proof-of-concept page, with the sandbox and GPU disabled, garbage collection exposed to JavaScript, and a fresh profile directory:

Bash
ASAN_OPTIONS=detect_odr_violation=0 ~/chromium/src/out/asan-release/chrome \
  --no-sandbox --disable-gpu \
  --js-flags="--expose-gc" \
  --user-data-dir=/tmp/poc-$(date +%s) \
  ~/chromium/src/issue_webrtc032/poc.html

The renderer crashes with a heap-use-after-free within seconds of the SCTP association establishing. No user interaction is required.

Finding it

The starting point is the shape of AllocateSctpSids. It walks the controller's channel list, assigns a stream ID to every channel that does not yet have one, and pushes the channel into a local vector:

C++
// third_party/webrtc/pc/data_channel_controller.cc:455-488
void DataChannelController::AllocateSctpSids(SSLRole role) {
  std::vector<SctpDataChannel*> channels_to_start;
  // ...
  for (auto it = sctp_data_channels_n_.begin();
       it != sctp_data_channels_n_.end();) {
    if (!(*it)->sid_n().has_value()) {
      std::optional<StreamId> sid = sid_allocator_.AllocateSid(role);
      if (sid.has_value()) {
        (*it)->SetSctpSid_n(*sid);
        AddSctpDataStream(*sid, (*it)->priority());
        channels_to_start.push_back((*it).get());  // raw pointer extracted
      }
      // ...
    }
    ++it;
  }
  if (ready_to_send) {
    for (auto* channel : channels_to_start) {
      channel->OnTransportReady();  // uses raw pointer after potential free
    }
  }
}

The vector holds raw pointers, not scoped_refptr, so nothing in it keeps a channel alive. A comment in the code acknowledges that "OnTransportReady can cause sending, and sending may fail and cause channel to close," which is exactly the situation the raw pointer cannot survive.

Following OnTransportReady leads to UpdateState. For a channel in kConnecting with handshake_state_ equal to kHandshakeShouldSendOpen, it serialises the DCEP OPEN message and hands it to SendControlMessage:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:791-822
void SctpDataChannel::UpdateState() {
  switch (state_) {
    case kConnecting: {
      if (connected_to_transport() && controller_) {
        if (handshake_state_ == kHandshakeShouldSendOpen) {
          CopyOnWriteBuffer payload;
          WriteDataChannelOpenMessage(label_, protocol_, priority_, ordered_,
                                      max_retransmits_, max_retransmit_time_,
                                      &payload);
          SendControlMessage(payload);
        }
        // ... execution continues here after SendControlMessage returns
        if (handshake_state_ == kHandshakeReady ||
            handshake_state_ == kHandshakeWaitingForAck) {
          SetState(kOpen);
        }
      }
      break;
    }
    case kOpen: {  // line 823: the UAF read occurs here
      break;
    }
    // ...
  }
}

The important detail is that execution continues in UpdateState after SendControlMessage returns, and the switch is then evaluated against state_ again. If the send failed and the channel was torn down in the meantime, that read touches freed memory.

Exploitation

Step 1: make the DCEP OPEN message large

The attacker controls the label length, and the label is part of the DCEP OPEN payload: 12 bytes of header plus the label and protocol strings. Creating data channels with labels of approximately 2000 bytes makes the OPEN message roughly 2012 bytes.

Step 2: shrink the negotiated max-message-size

The attacker also controls the remote SDP. The a=max-message-size attribute sets the limit that DcSctpTransport::SendData enforces:

C++
// third_party/webrtc/media/sctp/dcsctp_transport.cc:341-348
auto max_message_size = socket_->options().max_message_size;
if (max_message_size > 0 && payload.size() > max_message_size) {
  return RTCError(RTCErrorType::INVALID_RANGE);
}

Munging the answer SDP to set max-message-size to 10 guarantees that the roughly 2012-byte OPEN message exceeds the limit. The check is a plain size comparison, so the failure is deterministic.

Step 3: let the failure destroy the channel

SendControlMessage treats any error from controller_->SendData as fatal for the channel:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:970-1003
bool SctpDataChannel::SendControlMessage(const CopyOnWriteBuffer& buffer) {
  RTCError err = controller_->SendData(*id_n_, send_params, buffer);
  if (!err.ok()) {
    CloseAbruptlyWithError(err);
  }
  return err.ok();
}

CloseAbruptlyWithError moves the channel through kClosing to kClosed via SetState, and every SetState notifies the controller:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:853-865
void SctpDataChannel::SetState(DataState state) {
  state_ = state;
  if (observer_)
    observer_->OnStateChange();
  if (controller_)
    controller_->OnChannelStateChanged(this, state_);
}

On kClosed, the controller erases the channel from sctp_data_channels_n_:

C++
// third_party/webrtc/pc/data_channel_controller.cc:110-119
void DataChannelController::OnChannelStateChanged(
    SctpDataChannel* channel,
    DataChannelInterface::DataState state) {
  if (state == DataChannelInterface::DataState::kClosed)
    OnSctpDataChannelClosed(channel);
  // ...
}

// third_party/webrtc/pc/data_channel_controller.cc:497-508
void DataChannelController::OnSctpDataChannelClosed(SctpDataChannel* channel) {
  auto it = absl::c_find_if(sctp_data_channels_n_,
                            [&](const auto& c) { return c.get() == channel; });
  if (it != sctp_data_channels_n_.end()) {
    sctp_data_channels_n_.erase(it);  // drops the scoped_refptr
  }
}

If the page does not retain a reference to the RTCDataChannel wrapper, the scoped_refptr in sctp_data_channels_n_ is the last reference. Erasing it destroys the SctpDataChannel object. Control unwinds back through CloseAbruptlyWithError and SendControlMessage into UpdateState, which evaluates the switch against state_, reading freed memory at offset 232 within the deallocated 312-byte region.

Step 4: observe the crash

ASAN reports the read in UpdateState at sctp_data_channel.cc:823, reached from AllocateSctpSids at data_channel_controller.cc:501, which is itself reached from DcSctpTransport::OnConnected when the SCTP association comes up:

Text
==2497007==ERROR: AddressSanitizer: heap-use-after-free on address 0x7c1bb8d10ba8 at pc 0x7efc2bf06be6 bp 0x7afaac6c5370 sp 0x7afaac6c5368
READ of size 4 at 0x7c1bb8d10ba8 thread T12 (WebRTC_W_and_N)
    #0 0x7efc2bf06be5 in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:823:13
    #1 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16
    #2 0x7efc2bcb241f in non-virtual thunk to webrtc::DcSctpTransport::OnConnected() third_party/webrtc/media/sctp/dcsctp_transport.cc:581:25

The free stack shows the object being released from OnSctpDataChannelClosed, called from OnChannelStateChanged, called from SendControlMessage at sctp_data_channel.cc:1013, called from UpdateState at line 817:

Text
0x7c1bb8d10ba8 is located 232 bytes inside of 312-byte region [0x7c1bb8d10ac0,0x7c1bb8d10bf8)
freed by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500cdc2 in operator delete(void*, unsigned long) (out/asan-release/chrome+0x681cdc2) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf0e39c in webrtc::RefCountedObject<webrtc::SctpDataChannel>::Release() const third_party/webrtc/rtc_base/ref_counted_object.h:42:7
    #2 0x7efc2bdbb4bb in webrtc::DataChannelController::OnSctpDataChannelClosed(webrtc::SctpDataChannel*) third_party/webrtc/api/scoped_refptr.h:105:13
    #3 0x7efc2bdbaf32 in webrtc::DataChannelController::OnChannelStateChanged(webrtc::SctpDataChannel*, webrtc::DataChannelInterface::DataState) third_party/webrtc/pc/data_channel_controller.cc:119:5
    #4 0x7efc2bf0b244 in webrtc::SctpDataChannel::SendControlMessage(webrtc::CopyOnWriteBuffer const&) third_party/webrtc/pc/sctp_data_channel.cc:1013:5
    #5 0x7efc2bf0655c in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:817:11
    #6 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16

The allocation stack confirms the object was created through DataChannelController::CreateDataChannel and SctpDataChannel::Create:

Text
previously allocated by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500c1bd in operator new(unsigned long) (out/asan-release/chrome+0x681c1bd) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf04232 in webrtc::SctpDataChannel::Create(webrtc::WeakPtr<webrtc::SctpDataChannelControllerInterface>, std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, bool, webrtc::InternalDataChannelInit const&, webrtc::Thread*, webrtc::Thread*) third_party/webrtc/api/make_ref_counted.h:90:27
    #2 0x7efc2bdbf7c9 in webrtc::DataChannelController::CreateDataChannel(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, webrtc::InternalDataChannelInit&) third_party/webrtc/pc/data_channel_controller.cc:409:44

The summary line names the fault precisely:

Text
SUMMARY: AddressSanitizer: heap-use-after-free third_party/webrtc/pc/sctp_data_channel.cc:823:13 in webrtc::SctpDataChannel::UpdateState()

The ASAN additional info section records the mitigation status:

Text
MiraclePtr Status: NOT PROTECTED
No raw_ptr<T> access to this region was detected prior to this crash.
This crash is still exploitable with MiraclePtr.

Root cause

AllocateSctpSids stores raw SctpDataChannel* pointers in channels_to_start and then calls OnTransportReady on each. That call can synchronously send the DCEP OPEN message, and the send can fail because the payload exceeds the negotiated max-message-size. The failure path calls CloseAbruptlyWithError, which drives the channel to kClosed, which makes the controller erase the channel's scoped_refptr from sctp_data_channels_n_. When the page holds no other reference, that erase is the last release and the object is destroyed. The caller then continues with its dangling raw pointer and reads state_ in the switch at sctp_data_channel.cc:823.

The code comment already anticipated that sending may fail and close the channel, but the vector was not changed to hold owning references. MiraclePtr does not help because the access is not through a raw_ptr<T>; the ASAN report states that no raw_ptr<T> access to the region was detected and that the crash is still exploitable with MiraclePtr.

Impact

A web page can crash the renderer process deterministically, without user interaction, within seconds of the SCTP association establishing. The report describes the outcome as a renderer crash and does not demonstrate code execution or any other impact beyond the use-after-free itself. The bug affects all platforms.

Fix

The report does not describe a fix. The report does not describe a fix.

Variants to test

  1. Other synchronous failure paths from OnTransportReady. Any error returned by controller_->SendData during the OPEN handshake reaches CloseAbruptlyWithError. Try to make the send fail for reasons other than size, and check whether the same freed-object read appears at sctp_data_channel.cc:823.
  2. Other callers that iterate raw pointers over sctp_data_channels_n_. Look for loops that call into channel code which can re-enter OnChannelStateChanged and erase from the same vector. A positive result is an ASAN heap-use-after-free whose free stack passes through OnSctpDataChannelClosed.
  3. Labels near the boundary. Vary the label length around the negotiated max-message-size and confirm the crash appears exactly when the serialised OPEN message exceeds the limit, which shows the size check is the trigger rather than a timing artefact.
  4. Reference retention. Keep a JavaScript reference to the RTCDataChannel wrapper and confirm the crash disappears, which supports the explanation that the controller's scoped_refptr was the last reference.
  5. Other control messages. The same SendControlMessage path handles other DCEP frames; check whether a failure while sending any of them can close a channel that a caller still holds by raw pointer.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 21 min read.

What happened, in plain words

A web page can make the browser's own networking code read from a piece of memory that has already been thrown away. In programming terms that is called a use-after-free: the program frees a block of memory, then keeps using a pointer to it as if it were still there. The result here is that the part of Chrome that renders the page (the renderer) crashes. The report describes only a crash; it does not show any way to run attacker code or do anything else with the bug.

The feature involved is WebRTC data channels. WebRTC is the set of browser technologies that let two browsers talk directly to each other, for example for a video call. A data channel is a side channel inside that connection for sending arbitrary bytes, like a pipe between the two pages. Underneath, the bytes travel over SCTP, a protocol for reliable message delivery, and that SCTP traffic is wrapped inside DTLS, an encryption layer. All of this is standard browser plumbing that a page can start with a few lines of JavaScript.

Before a data channel can carry data, the two sides perform a small handshake. The first message is called DCEP OPEN (DCEP stands for Data Channel Establishment Protocol). It is a tiny control frame that carries the channel's label (a name chosen by the page), its protocol string, a priority and some reliability settings. The report found that if sending this OPEN message fails, the channel object is destroyed while the code that asked for the send is still holding a pointer to it. That leftover pointer is then used, and the browser reads freed memory.

The important part for a beginner is that this is not a rare race. The page can arrange the failure on purpose, every time, by choosing a long channel label and by editing the connection description (the SDP) that the other side sends back so that it advertises a very small maximum message size. The report says the bug affects all platforms and that a Chrome memory protection called MiraclePtr does not cover this code path.

Context

WebRTC data channels let a web page open a peer-to-peer byte stream over an SCTP association carried inside DTLS. The browser side of that machinery lives in third_party/webrtc/pc/: DataChannelController owns the set of SctpDataChannel objects, allocates stream IDs once the transport is ready, and drives each channel through its handshake. The handshake itself is the DCEP OPEN message, a small control frame containing the channel label, protocol, priority and reliability parameters.

A few of those words deserve a plain explanation before we go further.

  • An API is a defined way for one piece of software to ask another piece of software to do something. The page's JavaScript calls the WebRTC API; the browser's internal C++ code calls other internal APIs. The bug lives entirely inside the browser's internal APIs, but the page can reach it through the public one.
  • A pointer is a number that says where a piece of data sits in memory, like a house address. A raw pointer is just the address with no safety net: nothing checks that the house is still standing when you knock.
  • A reference count is a tally of how many parts of the program are currently using an object. When the tally drops to zero, the object is deleted. A scoped_refptr is a C++ helper that holds one of those tallies and gives it back automatically when it goes out of scope, so the object cannot vanish while you still hold it.
  • SDP (Session Description Protocol) is a text format that two WebRTC peers exchange to describe what they can do: which codecs, which addresses, and various limits. It is not secret; the page can read and modify it before handing it to the browser.
  • max-message-size is one of the limits advertised in SDP. It says how large a single SCTP message the other side is willing to receive.

This report describes a use-after-free in that handshake path. DataChannelController::AllocateSctpSids collects the channels it is about to start in a vector of raw pointers, then calls OnTransportReady on each. Sending the DCEP OPEN message can fail synchronously, and the failure path destroys the channel while the caller still holds the dangling pointer. A page can trigger it deterministically, with no race condition, by combining long channel labels with a manipulated remote SDP. The bug affects all platforms, and MiraclePtr does not protect this code path.

Setup

The issue was reproduced at commit bb43679d94d13. A commit is a saved snapshot of a source code repository; the long hexadecimal string is its identifier. The introducing commit is [redacted], dated 2025-12-22, authored by Harald Alvestrand, reviewed at https://webrtc-review.googlesource.com/c/src/+/435520. In other words, the report traced the bug back to the change that first brought it in, and points at the public code review page for that change.

The build is an ASAN release build of Chrome. ASAN stands for AddressSanitizer, a tool built into the compiler that watches every memory access and shouts when the program touches memory it has already freed. The build directory is named asan-release, an ASAN build of Chrome. The build command is:

Bash
autoninja -C ~/chromium/src/out/asan-release chrome

Line by line:

  • autoninja is the build tool used by Chromium.
  • -C ~/chromium/src/out/asan-release tells it to work in that output directory.
  • chrome is the build target.

Chrome is launched against a local proof-of-concept page, with the sandbox and GPU disabled, garbage collection exposed to JavaScript, and a fresh profile directory:

Bash
ASAN_OPTIONS=detect_odr_violation=0 ~/chromium/src/out/asan-release/chrome \
  --no-sandbox --disable-gpu \
  --js-flags="--expose-gc" \
  --user-data-dir=/tmp/poc-$(date +%s) \
  ~/chromium/src/issue_webrtc032/poc.html

Line by line:

  • ASAN_OPTIONS=detect_odr_violation=0 sets an environment variable read by ASAN.
  • ~/chromium/src/out/asan-release/chrome is the browser binary that was just built.
  • --no-sandbox runs the browser without its process sandbox.
  • --disable-gpu turns off graphics acceleration.
  • --js-flags="--expose-gc" passes a flag to the JavaScript engine that exposes the garbage collector to page scripts.
  • --user-data-dir=/tmp/poc-$(date +%s) gives the browser a fresh profile folder named with the current timestamp.
  • ~/chromium/src/issue_webrtc032/poc.html is the local test page that triggers the bug.

The renderer crashes with a heap-use-after-free within seconds of the SCTP association establishing. No user interaction is required. The renderer is the separate process that turns HTML and JavaScript into what you see; the SCTP association is the underlying reliable connection between the two peers, and it comes up automatically once the WebRTC negotiation finishes.

Finding it

The starting point is the shape of AllocateSctpSids. It walks the controller's channel list, assigns a stream ID to every channel that does not yet have one, and pushes the channel into a local vector:

C++
// third_party/webrtc/pc/data_channel_controller.cc:455-488
void DataChannelController::AllocateSctpSids(SSLRole role) {
  std::vector<SctpDataChannel*> channels_to_start;
  // ...
  for (auto it = sctp_data_channels_n_.begin();
       it != sctp_data_channels_n_.end();) {
    if (!(*it)->sid_n().has_value()) {
      std::optional<StreamId> sid = sid_allocator_.AllocateSid(role);
      if (sid.has_value()) {
        (*it)->SetSctpSid_n(*sid);
        AddSctpDataStream(*sid, (*it)->priority());
        channels_to_start.push_back((*it).get());  // raw pointer extracted
      }
      // ...
    }
    ++it;
  }
  if (ready_to_send) {
    for (auto* channel : channels_to_start) {
      channel->OnTransportReady();  // uses raw pointer after potential free
    }
  }
}

Line by line:

  • void DataChannelController::AllocateSctpSids(SSLRole role) { declares a function on the controller class. Its job is to hand out stream IDs (SIDs), which are small numbers that tell the two peers which data channel a message belongs to. SSLRole is the role parameter passed to the function.
  • std::vector<SctpDataChannel*> channels_to_start; creates an empty list. The important part is the type inside the angle brackets: SctpDataChannel*, a raw pointer. The list stores addresses, not ownership.
  • The for loop walks the controller's own list of channels, sctp_data_channels_n_. That list holds scoped_refptr values, which do keep objects alive.
  • if (!(*it)->sid_n().has_value()) checks whether the current channel already has a stream ID. If it does, it is skipped.
  • std::optional<StreamId> sid = sid_allocator_.AllocateSid(role); asks the allocator for a free stream ID. std::optional is a C++ type that can either hold a value or be empty.
  • if (sid.has_value()) runs the next lines only when an ID was actually handed out.
  • (*it)->SetSctpSid_n(*sid); stores the new ID on the channel.
  • AddSctpDataStream(*sid, (*it)->priority()); registers the stream with the transport layer, passing the channel's priority.
  • channels_to_start.push_back((*it).get()); adds the channel's raw address to the local list. The comment in the code marks this as the raw pointer extraction. .get() returns the bare address of the channel.
  • ++it; moves to the next channel.
  • if (ready_to_send) checks that the transport is ready for sending.
  • for (auto* channel : channels_to_start) loops over the collected raw addresses.
  • channel->OnTransportReady(); tells each channel the transport is up. The comment notes this uses the raw pointer after a potential free.

The vector holds raw pointers, not scoped_refptr, so nothing in it keeps a channel alive. A comment in the code acknowledges that "OnTransportReady can cause sending, and sending may fail and cause channel to close," which is exactly the situation the raw pointer cannot survive.

Following OnTransportReady leads to UpdateState. For a channel in kConnecting with handshake_state_ equal to kHandshakeShouldSendOpen, it serialises the DCEP OPEN message and hands it to SendControlMessage:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:791-822
void SctpDataChannel::UpdateState() {
  switch (state_) {
    case kConnecting: {
      if (connected_to_transport() && controller_) {
        if (handshake_state_ == kHandshakeShouldSendOpen) {
          CopyOnWriteBuffer payload;
          WriteDataChannelOpenMessage(label_, protocol_, priority_, ordered_,
                                      max_retransmits_, max_retransmit_time_,
                                      &payload);
          SendControlMessage(payload);
        }
        // ... execution continues here after SendControlMessage returns
        if (handshake_state_ == kHandshakeReady ||
            handshake_state_ == kHandshakeWaitingForAck) {
          SetState(kOpen);
        }
      }
      break;
    }
    case kOpen: {  // line 823: the UAF read occurs here
      break;
    }
    // ...
  }
}

Line by line:

  • void SctpDataChannel::UpdateState() { is the function that brings a channel's internal state in line with what has happened so far.
  • switch (state_) { looks at the channel's current state and jumps to the matching case. state_ is a member variable, a field stored inside the channel object itself.
  • case kConnecting: { handles the state where the channel is still being set up.
  • if (connected_to_transport() && controller_) checks that the transport is connected and that the channel still has a controller to talk to.
  • if (handshake_state_ == kHandshakeShouldSendOpen) checks whether the next handshake step is to send the OPEN message.
  • CopyOnWriteBuffer payload; creates an empty buffer to hold the message bytes.
  • WriteDataChannelOpenMessage(label_, protocol_, priority_, ordered_, max_retransmits_, max_retransmit_time_, &payload); serialises the OPEN message from the channel's settings into the buffer. The label and protocol strings are part of the result, which is why their length matters.
  • SendControlMessage(payload); sends it. This is the call that can fail and, through the failure path, destroy the channel.
  • The comment // ... execution continues here after SendControlMessage returns marks the danger: the function does not stop after the send.
  • if (handshake_state_ == kHandshakeReady || handshake_state_ == kHandshakeWaitingForAck) checks whether the handshake has moved on.
  • SetState(kOpen); marks the channel as open if so.
  • case kOpen: { // line 823: the UAF read occurs here is the branch that reads state_ again. If the object was freed during the send, this read touches freed memory.

The important detail is that execution continues in UpdateState after SendControlMessage returns, and the switch is then evaluated against state_ again. If the send failed and the channel was torn down in the meantime, that read touches freed memory.

Exploitation

Step 1: make the DCEP OPEN message large

The attacker controls the label length, and the label is part of the DCEP OPEN payload: 12 bytes of header plus the label and protocol strings. Creating data channels with labels of approximately 2000 bytes makes the OPEN message roughly 2012 bytes.

Why this step: the failure we want is a size check failing, so the message has to be big enough to exceed a limit we can shrink. The label is the easiest part of the message for a page to inflate, because it is just a string the page passes when it creates the channel.

Step 2: shrink the negotiated max-message-size

The attacker also controls the remote SDP. The a=max-message-size attribute sets the limit that DcSctpTransport::SendData enforces:

C++
// third_party/webrtc/media/sctp/dcsctp_transport.cc:341-348
auto max_message_size = socket_->options().max_message_size;
if (max_message_size > 0 && payload.size() > max_message_size) {
  return RTCError(RTCErrorType::INVALID_RANGE);
}

Line by line:

  • auto max_message_size = socket_->options().max_message_size; reads the limit that was agreed during negotiation and stored on the SCTP socket.
  • if (max_message_size > 0 && payload.size() > max_message_size) { checks two things: that a limit is set at all (zero means no limit), and that the message we are about to send is larger than it.
  • return RTCError(RTCErrorType::INVALID_RANGE); refuses the send with an error saying the value is out of range.

Munging the answer SDP to set max-message-size to 10 guarantees that the roughly 2012-byte OPEN message exceeds the limit. Munging here means editing the SDP text before passing it to the browser. The check is a plain size comparison, so the failure is deterministic: the same inputs always produce the same error, with no luck involved.

Step 3: let the failure destroy the channel

SendControlMessage treats any error from controller_->SendData as fatal for the channel:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:970-1003
bool SctpDataChannel::SendControlMessage(const CopyOnWriteBuffer& buffer) {
  RTCError err = controller_->SendData(*id_n_, send_params, buffer);
  if (!err.ok()) {
    CloseAbruptlyWithError(err);
  }
  return err.ok();
}

Line by line:

  • bool SctpDataChannel::SendControlMessage(const CopyOnWriteBuffer& buffer) { is the function that sends a control frame and reports success or failure as a boolean.
  • RTCError err = controller_->SendData(*id_n_, send_params, buffer); asks the controller to send the buffer on this channel's stream ID. The result is stored in err.
  • if (!err.ok()) { checks whether the send failed.
  • CloseAbruptlyWithError(err); closes the channel immediately because of that error. This is the call that starts the destruction.
  • return err.ok(); reports the outcome to the caller.

CloseAbruptlyWithError moves the channel through kClosing to kClosed via SetState, and every SetState notifies the controller:

C++
// third_party/webrtc/pc/sctp_data_channel.cc:853-865
void SctpDataChannel::SetState(DataState state) {
  state_ = state;
  if (observer_)
    observer_->OnStateChange();
  if (controller_)
    controller_->OnChannelStateChanged(this, state_);
}

Line by line:

  • void SctpDataChannel::SetState(DataState state) { is the function that changes the channel's state.
  • state_ = state; stores the new state in the object.
  • if (observer_) checks whether anything is watching this channel.
  • observer_->OnStateChange(); tells that observer the state changed.
  • if (controller_) checks whether the channel still has a controller.
  • controller_->OnChannelStateChanged(this, state_); tells the controller, passing a pointer to this channel and the new state. This is the notification that can lead to the channel being removed and freed.

On kClosed, the controller erases the channel from sctp_data_channels_n_:

C++
// third_party/webrtc/pc/data_channel_controller.cc:110-119
void DataChannelController::OnChannelStateChanged(
    SctpDataChannel* channel,
    DataChannelInterface::DataState state) {
  if (state == DataChannelInterface::DataState::kClosed)
    OnSctpDataChannelClosed(channel);
  // ...
}

// third_party/webrtc/pc/data_channel_controller.cc:497-508
void DataChannelController::OnSctpDataChannelClosed(SctpDataChannel* channel) {
  auto it = absl::c_find_if(sctp_data_channels_n_,
                            [&](const auto& c) { return c.get() == channel; });
  if (it != sctp_data_channels_n_.end()) {
    sctp_data_channels_n_.erase(it);  // drops the scoped_refptr
  }
}

Line by line:

  • void DataChannelController::OnChannelStateChanged( starts the controller's handler for state changes. It receives the channel pointer and the new state.
  • if (state == DataChannelInterface::DataState::kClosed) checks whether the channel has just closed.
  • OnSctpDataChannelClosed(channel); hands the channel to the cleanup function.
  • void DataChannelController::OnSctpDataChannelClosed(SctpDataChannel* channel) { is that cleanup function.
  • auto it = absl::c_find_if(sctp_data_channels_n_, searches the controller's list of channels.
  • [&](const auto& c) { return c.get() == channel; }); is the search condition: find the entry whose raw address matches the channel we were told about.
  • if (it != sctp_data_channels_n_.end()) { checks that the channel was actually found.
  • sctp_data_channels_n_.erase(it); // drops the scoped_refptr removes it from the list. The comment is the key: removing the entry drops the reference count that the list was holding.

If the page does not retain a reference to the RTCDataChannel wrapper, the scoped_refptr in sctp_data_channels_n_ is the last reference. Erasing it destroys the SctpDataChannel object. Control unwinds back through CloseAbruptlyWithError and SendControlMessage into UpdateState, which evaluates the switch against state_, reading freed memory at offset 232 within the deallocated 312-byte region.

In everyday terms: the page asked for a channel, the browser created an object for it, and the controller's list was the only thing keeping that object alive. The page deliberately does not keep its own handle, so when the list lets go, the object is gone. The function that started the send is still running and still has the old address, like someone reading a letter at a house that has just been demolished.

Step 4: observe the crash

ASAN reports the read in UpdateState at sctp_data_channel.cc:823, reached from AllocateSctpSids at data_channel_controller.cc:501, which is itself reached from DcSctpTransport::OnConnected when the SCTP association comes up:

Text
==2497007==ERROR: AddressSanitizer: heap-use-after-free on address 0x7c1bb8d10ba8 at pc 0x7efc2bf06be6 bp 0x7afaac6c5370 sp 0x7afaac6c5368
READ of size 4 at 0x7c1bb8d10ba8 thread T12 (WebRTC_W_and_N)
    #0 0x7efc2bf06be5 in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:823:13
    #1 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16
    #2 0x7efc2bcb241f in non-virtual thunk to webrtc::DcSctpTransport::OnConnected() third_party/webrtc/media/sctp/dcsctp_transport.cc:581:25

What this block says, in plain words:

  • ERROR: AddressSanitizer: heap-use-after-free is ASAN's verdict: the program used memory from the heap (the general-purpose memory pool) after freeing it.
  • on address 0x7c1bb8d10ba8 is the memory address involved. The pc, bp and sp values are the processor's instruction pointer, base pointer and stack pointer at the moment of the fault; they help a developer locate the exact instruction.
  • READ of size 4 means the program tried to read four bytes, which matches reading a small field such as the state value.
  • thread T12 (WebRTC_W_and_N) says which thread did it.
  • The numbered lines starting with #0, #1, #2 are the call stack: the chain of function calls that led to the fault, newest first. #0 is the read in UpdateState; #1 is AllocateSctpSids, which called it; #2 is DcSctpTransport::OnConnected, which called AllocateSctpSids when the SCTP connection came up.

The free stack shows the object being released from OnSctpDataChannelClosed, called from OnChannelStateChanged, called from SendControlMessage at sctp_data_channel.cc:1013, called from UpdateState at line 817:

Text
0x7c1bb8d10ba8 is located 232 bytes inside of 312-byte region [0x7c1bb8d10ac0,0x7c1bb8d10bf8)
freed by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500cdc2 in operator delete(void*, unsigned long) (out/asan-release/chrome+0x681cdc2) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf0e39c in webrtc::RefCountedObject<webrtc::SctpDataChannel>::Release() const third_party/webrtc/rtc_base/ref_counted_object.h:42:7
    #2 0x7efc2bdbb4bb in webrtc::DataChannelController::OnSctpDataChannelClosed(webrtc::SctpDataChannel*) third_party/webrtc/api/scoped_refptr.h:105:13
    #3 0x7efc2bdbaf32 in webrtc::DataChannelController::OnChannelStateChanged(webrtc::SctpDataChannel*, webrtc::DataChannelInterface::DataState) third_party/webrtc/pc/data_channel_controller.cc:119:5
    #4 0x7efc2bf0b244 in webrtc::SctpDataChannel::SendControlMessage(webrtc::CopyOnWriteBuffer const&) third_party/webrtc/pc/sctp_data_channel.cc:1013:5
    #5 0x7efc2bf0655c in webrtc::SctpDataChannel::UpdateState() third_party/webrtc/pc/sctp_data_channel.cc:817:11
    #6 0x7efc2bdbc17f in webrtc::DataChannelController::AllocateSctpSids(webrtc::SSLRole) third_party/webrtc/pc/data_channel_controller.cc:501:16

What this block says:

  • The first line tells us the bad address sits 232 bytes into a 312-byte block, and gives the block's start and end addresses. So the object was 312 bytes long and the field being read was 232 bytes from its start.
  • freed by thread T12 introduces the second call stack: the one that freed the memory, on the same thread.
  • #0 operator delete is the C++ memory release routine, the actual moment the block went back to the allocator.
  • #1 RefCountedObject<webrtc::SctpDataChannel>::Release() is the reference count dropping to zero, which is what triggers the delete.
  • #2 OnSctpDataChannelClosed is the controller function that erased the channel from its list and thereby dropped the last reference.
  • #3 OnChannelStateChanged is the notification that led there.
  • #4 SendControlMessage is where the failed send was handled.
  • #5 UpdateState is the function that called the send.
  • #6 AllocateSctpSids is the outer loop that started it all.

Put together, the two stacks tell the whole story: the same function, UpdateState, first caused the free (through the failed send) and then read the freed memory.

The allocation stack confirms the object was created through DataChannelController::CreateDataChannel and SctpDataChannel::Create:

Text
previously allocated by thread T12 (WebRTC_W_and_N) here:
    #0 0x55a45500c1bd in operator new(unsigned long) (out/asan-release/chrome+0x681c1bd) (BuildId: 436e46875e0ded00)
    #1 0x7efc2bf04232 in webrtc::SctpDataChannel::Create(webrtc::WeakPtr<webrtc::SctpDataChannelControllerInterface>, std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, bool, webrtc::InternalDataChannelInit const&, webrtc::Thread*, webrtc::Thread*) third_party/webrtc/api/make_ref_counted.h:90:27
    #2 0x7efc2bdbf7c9 in webrtc::DataChannelController::CreateDataChannel(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>, webrtc::InternalDataChannelInit&) third_party/webrtc/pc/data_channel_controller.cc:409:44

What this block says:

  • previously allocated by thread T12 introduces the third stack: where the memory originally came from.
  • #0 operator new is the C++ memory allocation routine.
  • #1 SctpDataChannel::Create is the factory function that built the channel object.
  • #2 DataChannelController::CreateDataChannel is the controller function that the page's request ultimately reached.

So ASAN gives three views of the same object: where it was born, where it died, and where it was used after death.

The summary line names the fault precisely:

Text
SUMMARY: AddressSanitizer: heap-use-after-free third_party/webrtc/pc/sctp_data_channel.cc:823:13 in webrtc::SctpDataChannel::UpdateState()

This is ASAN's one-line verdict: the bug class, the file and line, and the function. It is the line a developer reads first.

The ASAN additional info section records the mitigation status:

Text
MiraclePtr Status: NOT PROTECTED
No raw_ptr<T> access to this region was detected prior to this crash.
This crash is still exploitable with MiraclePtr.

MiraclePtr is a Chrome defence that makes certain pointer types (raw_ptr<T>) fail safely if the object they point at has been freed. This block says the access in this bug did not go through such a pointer, so the defence never had a chance to intervene, and the crash still happens even with MiraclePtr enabled.

Root cause

AllocateSctpSids stores raw SctpDataChannel* pointers in channels_to_start and then calls OnTransportReady on each. That call can synchronously send the DCEP OPEN message, and the send can fail because the payload exceeds the negotiated max-message-size. The failure path calls CloseAbruptlyWithError, which drives the channel to kClosed, which makes the controller erase the channel's scoped_refptr from sctp_data_channels_n_. When the page holds no other reference, that erase is the last release and the object is destroyed. The caller then continues with its dangling raw pointer and reads state_ in the switch at sctp_data_channel.cc:823.

The code comment already anticipated that sending may fail and close the channel, but the vector was not changed to hold owning references. MiraclePtr does not help because the access is not through a raw_ptr<T>; the ASAN report states that no raw_ptr<T> access to the region was detected and that the crash is still exploitable with MiraclePtr.

A useful comparison: imagine a librarian with a list of book titles written on sticky notes. The list of titles is the raw pointer vector. While the librarian is fetching one book, someone else can remove it from the shelf and throw it away. The sticky note still says where the book was, but the shelf space is empty or reused. A scoped_refptr would be like a checkout slip that prevents the book from being removed while you hold it.

Impact

A web page can crash the renderer process deterministically, without user interaction, within seconds of the SCTP association establishing. The report describes the outcome as a renderer crash and does not demonstrate code execution or any other impact beyond the use-after-free itself. The bug affects all platforms.

For a user, the visible effect is that the renderer process crashes.

Fix

The report does not describe a fix.

Variants to test

  1. Other synchronous failure paths from OnTransportReady. Any error returned by controller_->SendData during the OPEN handshake reaches CloseAbruptlyWithError. Try to make the send fail for reasons other than size, and check whether the same freed-object read appears at sctp_data_channel.cc:823.
  2. Other callers that iterate raw pointers over sctp_data_channels_n_. Look for loops that call into channel code which can re-enter OnChannelStateChanged and erase from the same vector. A positive result is an ASAN heap-use-after-free whose free stack passes through OnSctpDataChannelClosed.
  3. Labels near the boundary. Vary the label length around the negotiated max-message-size and confirm the crash appears exactly when the serialised OPEN message exceeds the limit, which shows the size check is the trigger rather than a timing artefact.
  4. Reference retention. Keep a JavaScript reference to the RTCDataChannel wrapper and confirm the crash disappears, which supports the explanation that the controller's scoped_refptr was the last reference.
  5. Other control messages. The same SendControlMessage path handles other DCEP frames; check whether a failure while sending any of them can close a channel that a caller still holds by raw pointer.

Glossary

  • API: a defined way for one piece of software to ask another to do something.
  • ASAN (AddressSanitizer): a compiler tool that detects memory errors such as use-after-free and reports them with call stacks.
  • Call stack: the chain of function calls currently in progress, shown newest first in a crash report.
  • Commit: a saved snapshot of a source code repository, identified by a long hexadecimal string.
  • Data channel: a WebRTC feature that lets two browsers send arbitrary bytes to each other over a peer-to-peer connection.
  • DCEP (Data Channel Establishment Protocol): the small handshake protocol that opens a data channel, starting with an OPEN message.
  • DTLS: an encryption layer used to protect datagram traffic, including the SCTP traffic in WebRTC.
  • Garbage collector: the part of a JavaScript engine that reclaims memory no longer used by scripts.
  • Heap: the general-purpose pool of memory a program allocates objects from at runtime.
  • max-message-size: an SDP attribute stating the largest single SCTP message the peer will accept.
  • MiraclePtr: a Chrome memory-safety defence that makes certain pointer types fail safely when their target has been freed.
  • Pointer: a value that holds the memory address of another piece of data.
  • Raw pointer: a bare memory address with no ownership or safety tracking.
  • Reference count: a tally of how many parts of a program are using an object; the object is deleted when the tally reaches zero.
  • Renderer: the browser process that turns HTML and JavaScript into a visible page.
  • SCTP: a reliable message-oriented transport protocol used underneath WebRTC data channels.
  • SDP (Session Description Protocol): a text format peers exchange to describe their capabilities and limits.
  • scoped_refptr: a C++ smart pointer that holds a reference count and releases it automatically when it goes out of scope.
  • Stream ID (SID): a small number identifying which data channel a message belongs to.
  • Use-after-free: a bug where a program keeps using memory after it has been freed.
  • WebRTC: the browser technology for direct real-time communication between peers, such as calls and data channels.

More by c6eed09fc8b174b0f3eebedcceb1e792

View all

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