Skip to content
Race condition Disclosed report Advanced CVE-2025-13012

AddressSanitizer: heap-use-after-free and attempting-double-free in CrashStatsLogForwarder (potentially due to race-condition)

A data race between the main thread and the render thread on a shared vector of strings inside CrashStatsLogForwarder caused one thread to free a string's buffer while the other was still reading it. This produced AddressSanitizer heap-use-after-free and double-free crashes when many graphics critical error annotations were logged.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 16 days
  • Paid in 16 days
  • Disclosed after 16 days

Created attachment 9516939 log_asan_uaf1_esr140.txt

Summary

When simulating swgl gl.cc new_buf realloc failure as on my previous bug 1975837, it able to generate a lot of Crash Annotation GraphicsCriticalError on log stdout, interestingly in rare case it able to hit AddressSanitizer: heap-use-after-free and attempting-double-free in CrashStatsLogForwarder.

Analysis

From the ASan log and local LLM analysis, the crash is probably caused by unsynchronised access/data race between main thread (T0) and render thread (T52) to a shared std::vector<std::string> that lives in CrashStatsLogForwarder instance, as follow:

  1. Render thread (T52)
  • Creates a temporary std::string (S₁).
  • Stores that string into an element of CrashStatsLogForwarder::mStrings. The vector now owns S₁ and its internal character buffer.
  1. Main thread (T0)
  • Calls CrashStatsLogForwarder::UpdateStringsVector(const std::string&) with a different string (S₂).
  • Inside that function the code assigns (S₂) into the same vector slot that already holds (S₁)
  • The assignment also triggers the destructor of the old string (std::string::_Rep::_M_dispose).
  • That destructor calls operator delete to free the character buffer that belonged to S₁.
  1. Render thread (T52) (later)
  • Still iterating over mStrings in UpdateCrashReport() and tries to write S₁ to an std::ostream.
  • The stream’s operator<< internally calls std::char_traits<char>::copy, which uses memcpy().
  • It now read/copies (S₁) from the dangling buffer that was already freed by the main thread, resulting the ASan "heap‑use‑after‑free".

I'm able to reproduce the UAF and double-free on Firefox ESR140 build (commit 9571910, Sep 27 2025) and Firefox ESR128 build (commit 4442784, Jul 3 2025)

I haven't receive the UAF or double-free report on Firefox Nightly build yet, probably due to new assertion Hit MOZ_CRASH(bug: unable to lock indirect) at gfx/wr/webrender/src/compositor/sw_compositor.rs:164, so it crash early and won't generate a lot Crash Annotation GraphicsCriticalError log.

The original report as published on Mozilla's Bugzilla, by Irvan Kurniawan. 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 shared string vector in CrashStatsLogForwarder is accessed by the main and render threads without synchronisation, so one thread frees a string buffer while the other still reads it.

Impact

The race could crash the browser through memory corruption; the text notes it was only seen in rare cases and not yet on Nightly, where an earlier assertion may stop it.

What the attacker needed

Swgl realloc failure simulated; many graphics critical error logs; race timing between two threads

How it was found

  1. Simulate a swgl gl.cc new_buf realloc failure as in the earlier bug.
  2. Generate many Crash Annotation GraphicsCriticalError entries on stdout.
  3. Observe the AddressSanitizer heap-use-after-free and attempting-double-free reports in CrashStatsLogForwarder.

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

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

A program can run several threads at once, and they sometimes share the same memory. Here two threads changed and read the same list of text strings without coordinating, so one thread deleted a string while the other was still using it. That is called a use-after-free, and it can crash the browser or, in principle, corrupt memory.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by Irvan Kurniawan

View all

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

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.