Skip to content
Memory corruption Disclosed report Advanced CVE-2025-1931

heap-use-after-free in WebTransportChild::RecvRemoteClosed

A use-after-free occurs in Firefox's WebTransport child code because the IPC channel object holds the owning WebTransport as a raw pointer, and RecvRemoteClosed triggers Cleanup which resolves a promise and runs user script that can release the last reference. An attacker could potentially cause memory corruption in the browser process handling WebTransport.

sherkito Follow

Originally disclosed on Mozilla

  • Fixed in 8 days
  • Paid in 6 months
  • Disclosed after 8 days
Text
Created attachment 9462034
asan.log

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0
Firefox for Android

Steps to reproduce:

`class WebTransportChild : public PWebTransportChild {
 public:
  NS_INLINE_DECL_REFCOUNTING(WebTransportChild)
  explicit WebTransportChild(WebTransport* aTransport)
      : mTransport(aTransport) {}
 ...
 protected:
  WebTransport* mTransport;  // WebTransport holds a strong reference to us, and
                             // calls Shutdown() before releasing it
  virtual ~WebTransportChild() { MOZ_ASSERT(!mTransport); }
}; [0]`

`void WebTransport::Cleanup(WebTransportError* aError,
                           const WebTransportCloseInfo* aCloseInfo,
                           ErrorResult& aRv) {
   ...
  // Step 12:
  if (aCloseInfo) {
    // 12.1: Resolve closed with closeInfo.
    LOG(("Resolving mClosed with closeinfo"));
    mClosed->MaybeResolve(*aCloseInfo); [1]
    // 12.2: Assert: ready is settled.
    MOZ_ASSERT(mReady->State() != Promise::PromiseState::Pending);
    // 12.3: Close incomingBidirectionalStreams
    // This keeps the clang-plugin happy
    RefPtr<ReadableStream> stream = mIncomingBidirectionalStreams;
    stream->CloseNative(cx, IgnoreErrors());
    // 12.4: Close incomingUnidirectionalStreams
    stream = mIncomingUnidirectionalStreams;
    stream->CloseNative(cx, IgnoreErrors());`

The WebTransport Renderer IPC channel objectmanages the WebTransport Owner object as a raw pointer. [0] 

 The vulnerability occurs because the Cleanup function is called in the RecvRemoteClosed function, and a user event is called in that function. [1]

`https://searchfox.org/mozilla-central/source/dom/webtransport/child/WebTransportChild.h#51 [0]`
`https://searchfox.org/mozilla-central/source/dom/webtransport/child/WebTransportChild.cpp#34 [1]`

The http3 server was created using the open source `https://github.com/aiortc/aioquic/tree/main` and the demo.py `wt` function code was edited.

An easy patch that I thought of would be to either pass a WebTransport object to the stack in RecvRemoteClosed as a RefPtr, or check by handling WeakPtr since there is no part of the code that references the WebTransport object later.

The original report as published on Mozilla's Bugzilla, by sherkito. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the IPC child object stores a raw pointer to its owner, and RecvRemoteClosed calls Cleanup which resolves a promise, running user script that can drop the last reference and free the owner while it is still in use.

What the attacker needed

A WebTransport-capable HTTP/3 server; victim visits a page using WebTransport; server closes the connection remotely

The fix

The reporter suggests holding the WebTransport as a RefPtr on the stack in RecvRemoteClosed, or using a WeakPtr check, since nothing later needs the object.

How it was found

  1. Set up an HTTP/3 server that supports WebTransport, for example using the aioquic demo.
  2. Open a WebTransport connection from the page to that server.
  3. Have the server close the connection remotely so RecvRemoteClosed runs.
  4. Observe the address-sanitizer report of a heap-use-after-free.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

WebTransport is a browser feature for sending data over a network connection. When the remote side closes the connection, the browser runs some cleanup code that can trigger JavaScript the page has registered. That JavaScript can cause the object holding the connection to be freed while the cleanup code is still using it, which is a use-after-free: reading memory that has already been released.

What is Memory corruption?

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

More by sherkito

View all

3 more disclosed reports, best first.

More from Mozilla

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.