Skip to content
Memory corruption Advisory Advanced CVE-2024-5847

Use after free in PDFium (CVE-2024-5847)

A manual code audit found that CPDFSDK_FormFillEnvironment::OnFormat calls ResetFieldAppearance, which may invoke JavaScript and free the widget or interactive form object, then uses those pointers without revalidation. An attacker could potentially trigger a use-after-free, though the reporter has no proof of concept and is unsure whether it is exploitable.

Han Zheng Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 25 days

Steps to reproduce the problem

It's a manual audit result, so there is no poc for now. Not sure if it's exploitable. now I'm trying to work on a poc.

Problem Description

in function CPDFSDK_FormFillEnvironment::OnFormat, there is a call to CPDFSDK_InteractiveForm::ResetFieldAppearance, which, according to crbug 40088733, could potentially involves in a js call, allows attacker to free the object pWidget or m_pInteractiveForm, further results in a Use-After-Free

C++
void CPDFSDK_FormFillEnvironment::OnFormat(ObservedPtr<CPDFSDK_Annot>& pAnnot) {

  // ...

  if (sValue.has_value()) {
    m_pInteractiveForm->ResetFieldAppearance(pWidget->GetFormField(), sValue); // <= potentially invoke a js call
    m_pInteractiveForm->UpdateField(pWidget->GetFormField()); // <= use without validation
  }
}

To be more precise, crbug 40088733 demonstrate that pWidget->ResetFieldAppearance(), a call to CPDFSDK_Widget::ResetFieldAppearance, can invoke the js call.

C++

void CPDFSDK_Widget::ResetFieldAppearance() {
  CPDF_FormField* pFormField = GetFormField();
  DCHECK(pFormField);
  m_pInteractiveForm->ResetFieldAppearance(pFormField, std::nullopt);
}

from which we could infer that CPDFSDK_Widget::ResetFieldAppearance is finally obtain CPDFSDK_Widget::GetFormField as the first argument and calling CPDFSDK_InteractiveForm::ResetFieldAppearance. which is the same as what is called in CPDFSDK_FormFillEnvironment::OnFormat. So m_pInteractiveForm->ResetFieldAppearance(pWidget->GetFormField(), sValue) may also invoke a js call and should be checked when returning.

Summary

Potential PDFium Use-After-Free in CPDFSDK_FormFillEnvironment::OnFormat

Custom Questions

Type of crash:

tab

Reporter credit:

Han Zheng (HexHive)

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A

The original report as published on the Chromium issue tracker, by Han Zheng (HexHive). Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 code calls a function that can run JavaScript and free the widget or interactive form, then uses those pointers without checking whether they are still valid.

Impact

This could potentially lead to a use-after-free, but the reporter has no proof of concept and is not sure it is exploitable.

What the attacker needed

Manual code audit; no proof of concept yet

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 frees an object from memory but keeps using it, like deleting a file and then trying to open it. Here, a formatting step in a PDF viewer can run JavaScript that frees the form objects, and the code then touches them again. The reporter found this by reading the code, not by running an exploit.

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 Han Zheng

View all

4 more disclosed reports, best first.

More from Google Chrome

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.