Skip to content
Memory corruption Disclosed report Advanced CVE-2024-4771

AddressSanitizer: heap-use-after-free gfx/thebes/gfxFontEntry.cpp in ForgetHashEntry after calloc failure on hb_object_create

A heap-use-after-free occurs in Firefox's font handling code when a memory allocation fails during blob creation, after user data has been freed but is still referenced by the hash-entry cleanup path. An attacker could potentially trigger a crash by causing the allocation to fail while loading crafted font data.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 3 days
  • Paid in 9 days
  • Disclosed after 3 days

Created attachment 9399060 ForgetHashEntry-heap-use-after-free-write-8.txt

On hb_blob_create_or_fail when the hb_object_create<hb_blob_t> calloc return nullptr, after user_data is freed, the user_data able to reused by ForgetHashEntry code.

Steps to reproduce

  1. Apply attached hb-blob-create-or-fail.patch
  2. Compile Firefox with AddressSanitizer
  3. Visit attached testcase-for-hb-blob-patch.html
  4. Firefox crashed with AddressSanitizer: heap-use-after-free

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 error path in hb_blob_create_or_fail frees user_data but leaves it reachable by ForgetHashEntry, which then accesses the freed memory.

Impact

A crafted page could crash the browser through a use-after-free, though the report only demonstrates a crash under a patched build with forced allocation failure.

What the attacker needed

Patched build forcing calloc failure; victim loads a crafted page

How it was found

  1. Apply the attached patch to the blob creation code
  2. Compile Firefox with AddressSanitizer enabled
  3. Open the attached test case page
  4. Observe the heap-use-after-free crash reported by AddressSanitizer

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.

When a program runs out of memory during a particular step, it frees some data but a later cleanup routine still uses that freed data. Using memory after it has been freed is dangerous because the contents can be replaced by something else, leading to crashes or worse. Here it was found with a tool called AddressSanitizer that detects such mistakes.

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

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.