Use After Free In HTMLTableElment::DeleteCaption
A raw pointer to a table caption element is used after it is removed by RemoveChild(), which triggers a synchronous DOMNodeRemoved event. An attacker could cause a use-after-free and crash Firefox by loading a page and interacting with the table.
Originally disclosed on Mozilla
- Fixed in 9 days
- Paid in 15 days
- Disclosed after 9 days
Created attachment 9041302
crash.html
I found a use after free by code review and have wrote a crashing proof of concept. Also there are at least two other use after frees in the same class. The problem is a raw pointer to a caption element is obtained. Its then passed to RemoveChild() which dispatches a sync DOMNodeRemoved event. I've attached a simple proof of concept. Wait for the page to load and then mouse over the table. Click the alert box and firefox should crash. This like pretty old code so I bet most versions of firefox are effected. Also there are at least two other use after frees in that file. I'll open up separate bug reports for those. It could be modified to where you don't have to mouse over the table to and click the alert box to trigger to the bug but I've worked so long and hard to try and find a bug and I finally found one so I'm reporting it ASAP!. In order to fix this issue I would recommend taking a strong reference to the caption object so it cant be removed.
HTMLTableElement::DeleteCaption()
{
HTMLTableCaptionElement* caption = GetCaption();
if (caption) {
mozilla::ErrorResult rv;
nsINode::RemoveChild(*caption, rv);
MOZ_ASSERT(!rv.Failed());
}
}
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 use-after-free could crash Firefox, and the reporter believes most versions are affected.
What the attacker needed
Victim loads a malicious page; victim mouses over the table; victim clicks an alert box
The fix
The issue should be fixed by taking a strong reference to the caption object so it cannot be removed while in use.
How it was found
- Load the attached proof-of-concept page.
- Wait for the page to load.
- Mouse over the table.
- Click the alert box.
- Firefox 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 use-after-free happens when a program keeps using memory after it has been freed. Here, the code gets a pointer to a table caption, removes the caption, and then still tries to use that pointer, which can crash the browser. The report includes a proof-of-concept page that triggers the crash when the user mouses over the table and clicks an alert.
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.