Skip to content
Memory corruption Disclosed report Advanced CVE-2022-22742

SEGV on unknown address 0x14141414 in nsTextFragment::CharAt

A use-after-free in Firefox's text fragment handling allows an attacker to control the crash address by manipulating the length of inserted text. The crash occurs after calling insertParagraph, with the address derived from the number of space or newline characters inserted via insertAdjacentText.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 9 days
  • Paid in 16 days
  • Disclosed after 9 days
Text
Created attachment 9249657
testcase.html

From the testcase after the `insertParagraph` executed, Firefox will crash with AV on 0x14141414 (32-bit) or 0x000014141414 (64-bit), the crash address is controllable through `insertAdjacentText` new line or space character length, on the testcase I'm using decimal `336860180`  which converted to hex `0x14141414`.

When execute `insertAdjacentText` to fill DOM with a lot of space character, the memory will increase, currently one new line or space character is equivalent to one SEGV address increase, it will be more interesting if there are workaround to optimize the memory to hit higher SEGV address.

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 a use-after-free in nsTextFragment::CharAt where the text fragment's buffer is freed but still accessed, and the freed memory is filled with attacker-controlled data (spaces/newlines) that determines the crash address.

What the attacker needed

Victim visits a malicious web page

How it was found

  1. Load the provided testcase HTML file in Firefox.
  2. Execute insertAdjacentText to fill the DOM with many space characters.
  3. Execute insertParagraph.
  4. Observe the crash at an address derived from the number of inserted characters.

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.

This is a bug in Firefox's internal memory management. When a web page inserts a lot of spaces or newlines into the page and then triggers a paragraph insertion, Firefox tries to read text from memory that has already been freed. The attacker can influence the memory address that causes the crash, which is a step toward potentially running malicious code.

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.