Use after free in PDFium (CVE-2026-9958)
A use-after-free in PDFium occurs when a linearized PDF aliases an array as both a NameTree /Limits array and a page's /Annots array, causing an inline annotation dictionary to be freed during link enumeration. An attacker could potentially exploit this to achieve arbitrary code execution in the renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 38 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 without the Chrome Security team. 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 exists in PDFium when handling linearized PDFs. By aliasing an array as both a NameTree /Limits array and a Page's /Annots array, an attacker can trigger the premature deletion of inline annotation dictionaries. This leads to a dangling raw pointer dereference during link enumeration.
Affected files:
third_party/pdfium/core/fpdfdoc/cpdf_nametree.cpppdf/pdfium/pdfium_page.ccthird_party/pdfium/core/fpdfapi/parser/cpdf_array.cppthird_party/pdfium/core/fpdfdoc/cpdf_annotlist.cpp
Estimated timestamp from git blame: 2025-08-29
Root Cause
In PDFium, the GetNodeLimitsAndSanitize() function (third_party/pdfium/core/fpdfdoc/cpdf_nametree.cpp) is responsible for sanitizing /Limits arrays during Name Tree traversal. If an array contains more than two elements, the function truncates it by calling RemoveAt in a loop:
while (pLimits->size() > 2) {
pLimits->RemoveAt(pLimits->size() - 1);
}
If the truncated elements are inline dictionaries (i.e., not indirect objects), the array holds their only reference. Truncating the array drops the reference count to zero, immediately freeing the dictionary.
Mitigation Bypass
PDFium typically mitigates this by promoting inline annotation dictionaries to indirect objects via CPDF_AnnotList, which is initialized during FORM_OnAfterLoadPage(). However, this mitigation can be bypassed in multi-page linearized PDFs during progressive loading:
PDFiumEngine::LoadBody()skips callingLoadForm()if the document is not yet complete and has more than one page.- When a page is requested early,
PDFiumPage::GetPage()is invoked. It checksif (engine_->form()), but sinceLoadForm()was skipped,engine_->form()returns null. - Consequently,
FORM_OnAfterLoadPage()is skipped. Inline link annotation dictionaries are never promoted to indirect objects.
Vulnerability Mechanism
An attacker can craft a PDF where a single array is aliased as both a NameTree node's /Limits and a page's /Annots. The array is populated with string limits and an inline Link Annotation dictionary.
During progressive loading, if the user interacts with the page or an accessibility query fires, PDFiumPage::CalculateLinks() is triggered. The execution flows as follows:
PDFiumPage::PopulateAnnotationLinks()iterates over the page's annotations usingFPDFLink_Enumerate().FPDFLink_Enumerateretrieves the inline Link Annotation from the aliased/Annotsarray and returns it as a rawFPDF_LINKhandle.PopulateAnnotationLinks()callsGetLinkTarget(), which attempts to resolve the link's destination viaFPDFLink_GetDest().- Resolving the destination triggers a Name Tree lookup (
CPDF_NameTree::LookupNamedDest). - The Name Tree traversal encounters the aliased array acting as a
/Limitsnode and callsGetNodeLimitsAndSanitize(). - The sanitization loop truncates the array, freeing the inline Link Annotation dictionary.
- Execution returns to
PopulateAnnotationLinks(), which subsequently callsFPDFLink_GetAnnotRect(link_annot). - The
link_annothandle is a raw C pointer that now points to freed memory. It is cast to aCPDF_Dictionary*and dereferenced, resulting in a Use-After-Free.
Note: These steps trace the potential vulnerability pathway based on static analysis.
Impact
This is a potential heap-based Use-After-Free in the sandboxed PDF renderer process. Because the FPDF_LINK handle is a raw pointer defined in PDFium's public C API (fpdfview.h), it is not protected by MiraclePtr (BackupRefPtr). An attacker who can predict or control heap allocations may be able to replace the freed CPDF_Dictionary to hijack virtual function calls, leading to arbitrary code execution in the renderer process.
Suggested Fix
There are two primary approaches to fixing this:
- Prevent Array Truncation: Modify
GetNodeLimitsAndSanitizeto return a sanitized copy or pair of strings without mutating the underlyingCPDF_Arrayin place. Name Tree traversals should generally be read-only operations. - Enforce AnnotList Initialization: Ensure that
FORM_OnAfterLoadPageis called consistently for linearized PDFs, even if the entire document hasn't finished loading, guaranteeing that inline annotations are properly promoted to indirect objects.
Evaluated with Chrome root at commit: 7353d249d9cacf9c7218e1d7b8a39cf39c72d646
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 NameTree sanitisation function mutates the /Limits array in place, freeing inline dictionaries that are still referenced elsewhere, and a mitigation that promotes inline annotations to indirect objects is skipped for linearized PDFs during progressive loading.
Impact
An attacker who can predict or control heap allocations may be able to replace the freed dictionary to hijack virtual function calls, leading to arbitrary code execution in the sandboxed renderer process.
What the attacker needed
Victim opens a crafted PDF; progressive loading of a linearized PDF; user interaction or accessibility query
The fix
The report suggests either preventing in-place truncation of the /Limits array or ensuring FORM_OnAfterLoadPage is called consistently for linearized PDFs.
How it was found
- Craft a PDF where one array is aliased as both a NameTree /Limits array and a page's /Annots array, containing an inline link annotation.
- During progressive loading, trigger PDFiumPage::CalculateLinks() by user interaction or an accessibility query.
- PopulateAnnotationLinks() iterates annotations and obtains a raw FPDF_LINK handle to the inline annotation.
- GetLinkTarget() resolves the link destination, causing a Name Tree lookup that calls GetNodeLimitsAndSanitize().
- The sanitisation loop truncates the aliased array, freeing the inline annotation dictionary.
- PopulateAnnotationLinks() then calls FPDFLink_GetAnnotRect() on the now-dangling pointer, causing a use-after-free.
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 is a bug where a program frees memory but then keeps using it, like deleting a file and then trying to open it. Here, a PDF can trick the viewer into freeing a small data structure and then reading it again, which could let an attacker run their own code. The report is based on static analysis, not a live 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.