Use after free in PDF (CVE-2026-11670)
A use-after-free was identified in PDFiumEngine where JavaScript triggered during the destruction of a PDF can call back into engine methods after internal vectors have been freed. An attacker could potentially achieve arbitrary code execution in the sandboxed renderer process by exploiting the resulting heap write.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 19 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential Use-After-Free (UAF) vulnerability exists in PDFiumEngine when nested JavaScript execution is triggered during the destruction sequence. This allows for re-entrant calls to engine logic after internal state vectors have been destroyed, resulting in heap writes on freed buffers.
Affected files:
pdf/pdfium/pdfium_engine.ccpdf/pdfium/pdfium_engine.hpdf/pdfium/pdfium_page.ccpdf/pdfium/pdfium_form_filler.ccthird_party/pdfium/fpdfsdk/formfiller/cffl_interactiveformfiller.cppthird_party/pdfium/fpdfsdk/cpdfsdk_formfillenvironment.cpp
Estimated timestamp from git blame: Unknown (Google3 checkout)
Summary
A potential Use-After-Free (UAF) vulnerability has been identified in the PDFiumEngine component of the PDF renderer. The issue stems from the order of member destruction in PDFiumEngine and the ability of attacker-controlled JavaScript to trigger re-entrant calls to engine methods after certain member variables have already been destroyed.
Technical Analysis
In pdf/pdfium/pdfium_engine.h, the declaration order of member variables determines their destruction order (reverse declaration order). Specifically:
pages_is declared at line 1205.visible_pages_,pending_pages_, anddeferred_page_unloads_are declared at lines 1208, 1211, and 1217 respectively.
During destruction of a PDFiumEngine object, the vectors at 1208-1217 are destroyed before the pages_ vector. When a std::vector is destroyed in libc++, its backing buffer is deallocated, but its internal pointers (begin, end, cap) remain in the object's memory as dangling pointers.
Following the destruction of these vectors, the pages_ vector begins its destruction. This involves invoking the destructor for each PDFiumPage element. If a page was re-established and focused during the destructor's 'Will Close' JavaScript phase, its subsequent closure during the destruction of pages_ can trigger a 'Blur' (/Bl) JavaScript action.
If this nested JavaScript calls back into the engine (e.g., by querying this.pageNum), it triggers PDFiumEngine::CalculateVisiblePages(). This function attempts to clear() and push_back() into the now-destroyed vectors (visible_pages_, pending_pages_, etc.).
Because the vector's internal pointers were not nulled during destruction, push_back may perform a placement-new write of a uint32_t (the page index) directly into the freed PartitionAlloc heap slot associated with the vector's former backing store. This provides a primitive for an arbitrary-value heap write into a freed buffer.
Potential Attack Sequence (Suggested)
- An attacker provides a PDF containing a document 'Will Close' action and a form field on a specific page with a 'Blur' action.
- When the user closes the PDF,
~PDFiumEngine()executes. - The 'Will Close' script runs and re-establishes focus on the form field, forcing the relevant page to be reloaded if it was previously unloaded.
- The
~PDFiumEngine()body completes, and member destruction begins. visible_pages_and related vectors are destroyed and their memory freed.- Destruction of the
pages_vector starts. When the focused page is destroyed, it triggersFPDF_ClosePage. - PDFium initiates the 'Blur' action for the focused field.
- The Blur JavaScript queries a property that triggers
CalculateVisiblePages()(e.g.,this.pageNum). CalculateVisiblePages()performs UAF writes into the destroyedvisible_pages_vector.
Impact
This vulnerability could allow an attacker to achieve arbitrary code execution (RCE) within the sandboxed renderer process. By utilizing heap-spraying techniques, an attacker might reclaim the freed vector buffers with controlled objects before the UAF write occurs.
Mitigation Status
This issue is likely not protected by MiraclePtr (BackupRefPtr) because it involves the internal pointers of std::vector within libc++, which are currently outside the scope of MiraclePtr protection.
Suggested Fix
The document's 'Will Close' action (FPDFDOC_AACTION_WC) should be executed at the very beginning of ~PDFiumEngine(), before any pages are unloaded or state is modified. Additionally, explicit steps should be taken to clear all form focus and page views before member destruction begins to ensure no JavaScript can be triggered during the teardown of the pages_ vector.
Evaluated with Chrome root at commit: 29093e11cf509e3593f6229e4b1b075cca356049
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 destruction order of member variables in PDFiumEngine allows JavaScript triggered during page destruction to call CalculateVisiblePages(), which writes to vectors that have already been destroyed.
Impact
This vulnerability could allow an attacker to achieve arbitrary code execution (RCE) within the sandboxed renderer process.
What the attacker needed
Victim opens a malicious PDF; victim closes the PDF
The fix
The document's 'Will Close' action should be executed at the very beginning of ~PDFiumEngine(), before any pages are unloaded or state is modified, and all form focus and page views should be cleared before member destruction begins.
How it was found
- An attacker provides a PDF containing a document 'Will Close' action and a form field on a specific page with a 'Blur' action.
- When the user closes the PDF, ~PDFiumEngine() executes.
- The 'Will Close' script runs and re-establishes focus on the form field, forcing the relevant page to be reloaded if it was previously unloaded.
- The ~PDFiumEngine() body completes, and member destruction begins.
- visible_pages_ and related vectors are destroyed and their memory freed.
- Destruction of the pages_ vector starts. When the focused page is destroyed, it triggers FPDF_ClosePage.
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 PDF is closed, the program frees memory it no longer needs. If a script inside the PDF runs at the wrong moment, it can make the program write data into memory that has already been freed. This is dangerous because an attacker might control what gets written and where, potentially leading to code execution.
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.