Use after free in PDFium (CVE-2024-5846)
A use-after-free vulnerability exists in PDFium's CFFL_ComboBox::SaveData where a JavaScript call can free the widget object, which is then used without validation. An attacker could potentially exploit this by crafting a malicious PDF with JavaScript, though the reporter is not certain it is exploitable.
- Fix shipped in 27 days
Steps to reproduce the problem
This is found by manual code audit, so there is no poc. I'm not 100% sure that it's exploitable, but according to the prior issue I report it to be safe. Now I'm working on a poc. This bug requires XFA enabled.
Problem Description
In function CFFL_ComboBox::SaveData, the m_pWidget->SetOptionSelection will invoke a js call, which allows to free the m_pWidget object via crafted js code in the pdf file. Afterward, the m_pWidget->ResetFieldAppearance was used without validation.
if (bSetValue) {
m_pWidget->SetValue(swText);
} else {
m_pWidget->GetSelectedIndex(0);
m_pWidget->SetOptionSelection(nCurSel); <= JS Call
}
ObservedPtr<CPDFSDK_Widget> observed_widget(m_pWidget);
ObservedPtr<CFFL_ComboBox> observed_this(this);
m_pWidget->ResetFieldAppearance(); <= Use without checking
For step 1 (invoke js), I slightly modify the condition of poc from 40064490, and successfully invoked the js call. For step 2 (free m_pWidget), I'm still working on that, but according to 40088733, it should be possible.
Summary
Security: Use-After-Free in CFFL_ComboBox::SaveData
Custom Questions
Type of crash:
tab
Reporter credit:
Han Zheng (HexHive)
Additional Data
Category: Security
Chrome Channel: Stable
Regression: N/A
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 missing check after a JavaScript call that can free the widget object, leading to use-after-free.
Impact
Could potentially lead to arbitrary code execution or a crash, but the reporter is not certain it is exploitable.
What the attacker needed
XFA enabled; victim opens a malicious PDF
How it was found
- Enable XFA in the PDF viewer.
- Craft a PDF with JavaScript that invokes the SetOptionSelection call.
- The JavaScript frees the m_pWidget object.
- The code then calls ResetFieldAppearance on the freed object.
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 memory safety bug in a PDF viewer component. When a PDF contains JavaScript, it can trigger a function that frees an object, but the program then tries to use that freed object, which can lead to a crash or potentially code execution. The reporter found it by reading the code and is still working on a proof of concept.
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.