Skip to content
DoS Disclosed report Advanced CVE-2025-9181

Free on address which was not realloc()-ed in js::GetNativeStackBaseImpl after realloc failure at pthread_getattr_np

A crash occurs in Firefox's native stack base helper when the underlying pthread attribute call fails to allocate memory, leaving an internal pointer uninitialised, and a later destroy call frees that invalid address. An attacker able to trigger the allocation failure could cause a segmentation fault, though the reporter could not reproduce it reliably without a patched system library.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 16 days
  • Paid in 17 days
  • Disclosed after 16 days
Text
Created attachment 9500304
log_minidump_00.txt

While fuzzing on Firefox Nightly 32-bit (Official Build) (BuildID=20250707093546) on Arch Linux (with original glibc), I found from minidump.txt it  crash at `SIGSEGV / SEGV_ACCERR` during execution of `js::newContext` to `free`. 

However, it still hard to reproduce the same, even after multiple tries.

After looking the code, the crash occurs at [NativeStack.cpp](https://searchfox.org/mozilla-central/source/js/src/util/NativeStack.cpp) in the function `js::GetNativeStackBaseImpl`:

'''cpp
void* js::GetNativeStackBaseImpl() {
 pthread_getattr_np(thread, &sattr);  // 1. realloc failure for &sattr inside pthread_getattr_np
...
...
 pthread_attr_destroy(&sattr); // 2. free on address which was not realloc()-ed on &sattr
'''

To reliably reproduce this bug, we can use patched glibc to simulate the `realloc` failure inside `pthread_getattr_np(thread, &sattr)` to return `ENOMEM`, leaving the `&sattr` address not realloc()-ed, then on `pthread_attr_destroy` it free on `&sattr` address (which not realloc()-ed) which cause the crash.

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 return value of pthread_getattr_np is not checked, so when it fails with ENOMEM the attribute structure is left uninitialised and pthread_attr_destroy frees an address that was never allocated.

Impact

The browser could crash with a segmentation fault, but only when the underlying allocation fails, which the reporter found hard to trigger without a patched system library.

What the attacker needed

32-bit Firefox build; memory allocation failure occurs; patched glibc to force the failure

How it was found

  1. Run a 32-bit Firefox Nightly build on Arch Linux with the original glibc.
  2. Fuzz the browser until js::newContext is reached and the stack base helper runs.
  3. Observe a SIGSEGV with SEGV_ACCERR in the minidump.
  4. To reproduce deterministically, use a patched glibc that makes the attribute call return ENOMEM.
  5. Watch the destroy call free the unallocated address and crash.

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.

Some programs ask the operating system for information about the current thread's stack. To do that, a system library allocates a small block of memory and fills it in. If that allocation fails, the program still tries to clean up the block as if it existed, which crashes the browser.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.