Embedded PDFs printed as vectors through the print process
Component: WebKit Printing | 72f58a7
Source/WebCore/platform/graphics/SharedPDFDocument.cpp
Source/WebCore/platform/graphics/cocoa/PDFKitDocument.mm
Source/WebKit/WebProcess/WebProcess.cpp
Under Site Isolation, a cross-site iframe lives in its own WebContent process. Printing therefore records a "remote snapshot", a display list that the GPU process replays and turns into a PDF. A recording context has no platform CGContext, so PDFKit cannot draw into it, and the PDF plugin could only rasterize embedded pages to a bitmap. Display lists are serialized across processes, with resources such as fonts and images cached by RenderingResourceIdentifier.
This commit adds a DrawPDFPage display-list item. The WebContent process records the page index, destination rect, a fallback bitmap, and the PDF data (sent once per document) through a new RemoteSnapshotRecorder IPC message. The GPU process stores the data as a SharedPDFDocument, whose drawPage() draws nothing and never parses. It forwards the data, without the fallback, to the print process, where a new PDFKitDocument factory parses and draws each page. If there is no print process or it does not reply, the GPU process draws the fallback bitmap. The print process also enters PDF Lockdown Mode when the page's process does.
WebContent(b.com) GPU process Print process
DrawPDFPage(idx, rect, -> SharedPDFDocument -> PDFKitDocument
fallback, PDF data) (holds data, no parse) (parses, draws pages)
| no print process / no reply
+--> draw fallback bitmap
Significance
Printing pages with cross-origin PDF embeds under Site Isolation no longer produces blurry, non-selectable text. Untrusted PDF bytes from a site-isolated renderer now travel through the GPU process into a PDFKit parser in the print process.
Audit directions
Treat the new RemoteSnapshotRecorder::drawPDFPage message as a fuzz target from a compromised WebContent process. Review deserialization of DrawPDFPage and its DisplayListData.serialization.in entry, and check whether pageIndex and the destination rect are validated against the actual page count. The "sent once per document" caching (cachePDFDocument/resolve) deserves scrutiny for identifier reuse and for items that reference an unresolved or mismatched document. Follow SharedPDFDocument versus PDFKitDocument lifetime across the GPU-to-print handoff, including the no-reply fallback, and confirm Lockdown Mode is entered in the print process before any parsing. DisplayListDataTester's new testPDFData and testInvalidPDFPages show the intended validation and are a good starting point.