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.
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
- Apply attached hb-blob-create-or-fail.patch
- Compile Firefox with AddressSanitizer
- Visit attached testcase-for-hb-blob-patch.html
- Firefox crashed with AddressSanitizer: heap-use-after-free
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
- Apply the attached patch to the blob creation code
- Compile Firefox with AddressSanitizer enabled
- Open the attached test case page
- 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.