Use after free in PDF (CVE-2026-9957)
A use-after-free write exists in Chrome's PDF Ink2 annotation feature because PDFium's FPDFPage_InsertObject silently frees a page object on validation failure while Chrome retains a dangling pointer. An attacker could craft a PDF that triggers this, potentially leading to remote code execution within the renderer sandbox.
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 vulnerability exists in Chrome's Ink2 annotation feature. FPDFPage_InsertObject silently frees a page object on validation failure, but the calling Chrome code assumes success and retains a dangling pointer that is subsequently used for memory writes during undo/redo or thumbnail generation.
Affected files:
pdf/pdfium/pdfium_ink_writer.ccthird_party/pdfium/fpdfsdk/fpdf_editpage.cpppdf/pdfium/pdfium_engine.ccthird_party/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp
Estimated timestamp from git blame: 2025-07-29
Root Cause Analysis
The vulnerability is a potential Use-After-Free (UAF) write in the PDF plugin process. It originates from an inconsistent ownership model between PDFium and its Chrome integration for the Ink2 feature.
-
Silent Free in
FPDFPage_InsertObject: The PDFium functionFPDFPage_InsertObject(inthird_party/pdfium/fpdfsdk/fpdf_editpage.cpp) takes ownership of anFPDF_PAGEOBJECTby wrapping it in astd::unique_ptr. It then validates the destination page by callingIsPageObject. If the validation fails, the function returns early. This causes theunique_ptrto go out of scope and delete theCPDF_PageObjectbefore it can be added to the page, effectively freeing it. Because the function has avoidreturn type, it provides no error signal to the caller. -
Normalization Gap:
IsPageObjectchecks if the page dictionary's/Typekey is a Name object with the exact value"Page". While PDFium'sCountPagesattempts to normalize malformed/Typekeys during document load, this normalization is skipped if the root/Pagesdictionary contains a valid/Countentry. Consequently, a maliciously crafted PDF can contain a page that loads normally but permanently fails theIsPageObjectcheck. -
Dangling Pointer Retention: The Chrome Ink2 writer (
pdf/pdfium/pdfium_ink_writer.cc) callsFPDFPage_InsertObjectviaWriteStrokeToPageand explicitly releases its ownership of the object. It assumes the operation succeeds and continues to cache the now-dangling raw pointer in its internalink_stroke_data_map inPDFiumEngine. -
UAF Write Sink: When a user undoes a stroke,
PDFiumEngine::UpdateStrokeActiveiterates through these cached (dangling) pointers and callsFPDFPageObj_SetIsActive. This eventually leads toCPDF_PageObject::SetIsActive(inthird_party/pdfium/core/fpdfapi/page/cpdf_pageobject.cpp), which performs a UAF write to theis_active_anddirty_boolean fields at fixed offsets within the freed object. A secondary sink exists via thumbnail generation, which temporarily toggles the active state.
Impact
This is a Use-After-Free write in the sandboxed PDF plugin process. Since the dangling handles are opaque C pointers (FPDF_PAGEOBJECT) and not base::raw_ptr<>, the vulnerability is not protected by MiraclePtr (BackupRefPtr). An attacker can control the number of freed objects and the timing of the subsequent write. Exploitation could lead to remote code execution within the renderer sandbox.
Potential Reproduction Steps
Note: These are suggested steps to trigger the issue, our tooling agent has not executed this code.
- Craft a PDF where the root
/Pagesdictionary has a valid/Countbut a child page dictionary has a malformed/Typeentry (e.g.,/Type (Page)as a literal string or an invalid name like/Type /Paje). - Open the PDF in Chrome and enter Annotate mode (via the toolbar pencil icon).
- Draw a stroke on the page. On mouse-up,
WriteStrokeToPagewill callFPDFPage_InsertObject. PDFium will silently free the created path objects while Chrome'sPDFiumEnginecaches the dangling handles. - Press Ctrl+Z (Undo) or trigger a thumbnail request. This will cause
PDFiumEngineto access the dangling pointers and perform UAF writes to theis_active_anddirty_fields.
Suggested Fix
FPDFPage_InsertObject and similar C API functions should not silently free objects on failure if they return void. They should either return a boolean/error code to indicate failure so the caller can handle the memory, or they should return the pointer back to the caller on failure.
Alternatively, if the API contract is strict about taking ownership regardless of success, the Ink2 integration code needs a mechanism to query the page state before yielding ownership, or Chrome needs to verify the object was successfully inserted (e.g., by checking object count) and prune dangling pointers if it wasn't. Updating the API to return a success boolean, similar to FPDFPage_InsertObjectAtIndex, is the most robust approach.
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 an inconsistent ownership model: FPDFPage_InsertObject takes ownership and frees the object on validation failure without signalling the caller, which then keeps a dangling pointer.
Impact
Exploitation could lead to remote code execution within the renderer sandbox, though the report notes the steps are suggested and not executed.
What the attacker needed
Victim opens a crafted PDF; victim uses Annotate mode; victim draws a stroke; victim undoes or triggers thumbnail
The fix
The API should be updated to return a success boolean so callers can handle failure, or the integration code should verify insertion and prune dangling pointers.
How it was found
- Craft a PDF with a valid /Count in the root /Pages dictionary but a child page dictionary with a malformed /Type entry.
- Open the PDF in Chrome and enter Annotate mode.
- Draw a stroke on the page, causing WriteStrokeToPage to call FPDFPage_InsertObject, which silently frees the object while Chrome caches dangling handles.
- Press Ctrl+Z (Undo) or trigger a thumbnail request, causing access to the dangling pointers and UAF writes.
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 memory but keeps using it, like deleting a file and then trying to open it. Here, a PDF function frees an object but the caller still thinks it exists and writes to it later. This could let an attacker control what happens in that freed memory, possibly running their own code.
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.