Crash SIGSEGV GetCaretFrameForNodeOffset at 0xffffffff (32-bit) or 0x0000ffffffff (64-bit) after malloc failure on nsTextFragment::SetTo
A memory allocation failure inside nsTextFragment::SetTo leaves the caret code with an invalid frame, so GetCaretFrameForNodeOffset dereferences a near-null pointer and crashes. An attacker could trigger this by exhausting memory and then invoking setRangeText, causing a denial of service.
Originally disclosed on Mozilla
- Fixed in 2 days
- Paid in 8 days
- Disclosed after 2 days
Created attachment 9401574 log_minidump_00.txt
When run testcase with fillMemory and setRangeText, on Firefox official Nightly 32-bit build I notice it able to crash on GetCaretFrameForNodeOffset at 0xffffffff on 32-bit build or 0x0000ffffffff 64-bit build, the crash occur after malloc failure on nsTextFragment::SetTo.
On original testcase I able to crash at GetCaretFrameForNodeOffset as attached log_minidump_00.txt, but it still require many tries to crash reliably, have to tweak the fillMemory code. For now to reproduce the crash reliably we can simulate the malloc failure on nsTextFragment::SetTo and visit the testcase-for-patch.html.
On local build I able to crash as described after checkout on commit Bug 1860328 - Track nsCaret position at the DOM level
Steps to reproduce:
- Apply nsTextFragment-setTo-failure.patch
- Compile Firefox
- Visit attached testcase-for-patch.html
- Firefox crash on GetCaretFrameForNodeOffset
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
Impact
The browser crashes, giving a denial of service; the report notes the original testcase needed many tries to crash reliably.
What the attacker needed
Memory exhaustion; victim loads a crafted page
How it was found
- Apply the patch that simulates the allocation failure
- Compile Firefox
- Visit the provided test page
- Firefox crashes in GetCaretFrameForNodeOffset
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, it should handle that gracefully. Here, a text-editing function fails to allocate memory, and the code that positions the blinking text cursor (the caret) then uses a broken reference and crashes the browser. An attacker who can force memory exhaustion and then trigger a text replacement can make the browser tab crash.
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.