Skip to content
DoS Disclosed report Advanced CVE-2024-6603

Free on address which was not realloced on pthread_attr_destroy (after realloc failure on pthread_getattr_np)

When Firefox repeatedly creates workers while memory is exhausted, a realloc inside pthread_getattr_np fails, leaving an internal attribute structure in a state where a later pthread_attr_destroy frees a pointer that was never reallocated. This causes a crash (a free of an address that was not realloced) in the browser process.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 32 days
  • Paid in 38 days
  • Disclosed after 32 days
Text
Created attachment 9400134
asan-free-which-not-realloced-pthread_attr_destroy.txt

When running Firefox to run new Worker repeatedly subsequently with fillMemory to fill the virtual memory, after a while it able to crash at `pthread_attr_destroy` -> `free`

I observe the crash occur after realloc failure on `nsThread::InitCommon()` at `pthread_getattr_np` line. From libc code, the realloc failure occur on following `__pthread_attr_setaffinity_np` code: 

'''
=> void *newp = realloc (iattr->extension->cpuset, cpusetsize);
if (newp == NULL)
  return ENOMEM;
'''

On `nsThread::InitCommon()` after `pthread_getattr_np(pthread_self(), &attr);` is called, after some code, it then run `pthread_attr_destroy(&attr);` which run `free (iattr->extension->cpuset);` which was not realloced.

Fix suggestion is to check `pthread_getattr_np(pthread_self(), &attr);` for non-zero return code or ENOMEM error.

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 after an internal realloc failure the attribute is still passed to pthread_attr_destroy, which frees a stale pointer.

What the attacker needed

Ability to run a page in Firefox; memory exhaustion via many workers

How it was found

  1. Fill virtual memory by repeatedly creating new Workers with fillMemory.
  2. Continue until a realloc inside pthread_getattr_np fails during nsThread::InitCommon().
  3. The code then calls pthread_attr_destroy on the attribute, which frees the non-realloced cpuset and crashes.

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 asks the system library for information about a thread, and the library tries to grow a small memory buffer. When memory is full that growth fails, but the program carries on and later tells the library to clean up, which frees memory that was never properly allocated. The result is a crash, which an attacker could trigger by making the browser run out of memory.

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.