Skip to content
Memory corruption Advisory Advanced CVE-2026-8001

Use after free in Printing (CVE-2026-8001)

A race condition in out-of-process printing allows a compromised renderer to replace and free a MetafilePlayer object while the browser's worker thread is still using it, causing a heap-use-after-free. This can crash the browser process.

c6eed09fc8b174b0f3eebedcceb1e792 Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 46 days

Unlocked MetafilePlayer access in OOP SpoolDocument leads to heap-use-after-free in the browser process

Summary

On Linux and macOS, where out-of-process (OOP) printing is enabled by default, the browser-process worker thread in PrintJobWorkerOop::SpoolDocument reads a MetafilePlayer pointer from PrintedDocument without holding the required lock. A concurrent call to SetDocument on the UI thread can replace and destroy that MetafilePlayer while the worker thread is still using it, resulting in a heap-use-after-free. A compromised renderer can trigger this race by sending a DidPrintDocument Mojo message during the window between GetMetafile and the subsequent dereference. The crash occurs in the browser process.

Bisect

Introducing Commit: 311052a7201fcffe5b820f950b5446fe1dee1235

Root Cause

PrintedDocument guards its mutable state with a lock and documents this requirement in the header:

C++
// printing/printed_document.h:73-75
// Retrieves the metafile with the data to print. Lock must be held when
// calling this function
const MetafilePlayer* GetMetafile();

The implementation of GetMetafile returns the raw pointer without any locking of its own:

C++
// printing/printed_document.cc:185-187
const MetafilePlayer* PrintedDocument::GetMetafile() {
  return mutable_.metafile_.get();
}

SetDocument replaces the metafile under the lock, destroying the previous one:

C++
// printing/printed_document.cc:172-176
void PrintedDocument::SetDocument(std::unique_ptr<MetafilePlayer> metafile) {
  {
    base::AutoLock lock(lock_);
    mutable_.metafile_ = std::move(metafile);
  }
  ...
}

The OOP printing worker violates the locking contract. PrintJobWorkerOop::SpoolDocument runs on a dedicated Printing_Worker thread and calls GetMetafile without holding the lock, then proceeds to call virtual methods on the returned pointer:

C++
// chrome/browser/printing/print_job_worker_oop.cc:285-296
bool PrintJobWorkerOop::SpoolDocument() {
  DCHECK(task_runner()->RunsTasksInCurrentSequence());

  const MetafilePlayer* metafile = document()->GetMetafile();
  DCHECK(metafile);
  base::MappedReadOnlyRegion region_mapping =
      metafile->GetDataAsSharedMemoryRegion();
  ...
}

Between the call to GetMetafile and the dereference of the returned pointer, the UI thread is free to process an incoming DidPrintDocument Mojo message from the renderer. That handler reaches PrintDocument, which calls SetDocument with a new metafile. SetDocument acquires the lock and moves a new unique_ptr into mutable_.metafile_, destroying the old MetafilePlayer that the worker thread still references.

C++
// chrome/browser/printing/print_view_manager_base.cc:295-300
std::unique_ptr<MetafileSkia> metafile = std::make_unique<MetafileSkia>();
CHECK(metafile->InitFromData(*print_data));

PrintedDocument* document = print_job_->document();
document->SetDocument(std::move(metafile));

The DidPrintDocument handler does not enforce single-use semantics. It only checks that the document cookie matches the active print job:

C++
// chrome/browser/printing/print_view_manager_base.cc:590-596
void PrintViewManagerBase::DidPrintDocument(
    mojom::DidPrintDocumentParamsPtr params,
    DidPrintDocumentCallback callback) {
  if (!PrintJobHasDocument(params->document_cookie)) {
    OnDidPrintDocument(std::move(callback), /*succeeded=*/false);
    return;
  }
  ...

A compromised renderer can therefore call DidPrintDocument repeatedly with a matching cookie, each call replacing the metafile. OOP printing is enabled by default on Linux and macOS via the kEnableOopPrintDrivers feature flag.

Reproduce

Note: this is a race condition that requires source patches and a configured CUPS printer to reproduce. Please do not use ClusterFuzz for validation; follow the manual steps below instead. Testing is recommended on Linux, where OOP printing and CUPS integration are most mature. On macOS the code path appears structurally identical, but we were unable to trigger the race despite the same patches and printer configuration.

Tested at commit 7c89d33808e551aed6122c1f324864784011c158 on Linux x86_64 with an ASAN build (is_asan = true, is_debug = false). A CUPS printer must be configured; here we use a cups-pdf virtual printer for verification (sudo apt install cups-pdf).

Apply the attached patch.diff. The patch inserts a Sleep(1s) on the browser side between GetMetafile and the dereference to stabilize the race timing. The renderer side repeatedly sends DidPrintDocument every 500ms starting from when the print-ready document is finalized.

cd ~/chromium/src
git apply issue_metafile_toctou/patch.diff
autoninja -C out/asan-release chrome

Launch:

ASAN_OPTIONS=detect_odr_violation=0 out/asan-release/chrome \
  --kiosk-printing \
  --user-data-dir=/tmp/poc-$(date +%s) \
  file://$(pwd)/issue_metafile_toctou/poc.html

The page calls window.print() after two seconds. The --kiosk-printing flag makes the print preview auto-accept without user interaction; it is not required for the vulnerability itself and can be omitted, in which case the user must manually select a system printer and click Print in the preview dialog. The browser process crashes with a heap-use-after-free within roughly ten seconds.

==4164388==ERROR: AddressSanitizer: heap-use-after-free on address 0x7cb1217e6c40 at pc 0x55fdefce502b bp 0x7b70f2bd4210 sp 0x7b70f2bd4208
READ of size 8 at 0x7cb1217e6c40 thread T35 (Printing_Worker)
    #0 0x55fdefce502a in printing::PrintJobWorkerOop::SpoolDocument() chrome/browser/printing/print_job_worker_oop.cc:293:17
    #1 0x55fdefc9591a in printing::PrintJobWorker::OnNewPage() chrome/browser/printing/print_job_worker.cc:180:10
    #2 0x55fdefce6694 in base::internal::Invoker<...>::RunOnce(base::internal::BindStateBase*) base/functional/bind_internal.h:740:12
    #3 0x7f71a2560622 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) base/functional/callback.h:155:12
    ...

0x7cb1217e6c40 is located 0 bytes inside of 408-byte region [0x7cb1217e6c40,0x7cb1217e6dd8)
freed by thread T0 (chrome) here:
    #0 0x55fde7c9c062 in operator delete(void*, unsigned long)
    #1 0x7f71765ec634 in printing::PrintedDocument::SetDocument(std::__Cr::unique_ptr<printing::MetafilePlayer, std::__Cr::default_delete<printing::MetafilePlayer>>) gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5
    #2 0x55fdefcf8962 in printing::PrintViewManagerBase::PrintDocument(scoped_refptr<base::RefCountedMemory>, gfx::Size const&, gfx::Rect const&, gfx::Point const&) chrome/browser/printing/print_view_manager_base.cc:300:13
    #3 0x55fdefcfc219 in printing::PrintViewManagerBase::OnComposePdfDoneImpl(...) chrome/browser/printing/print_view_manager_base.cc:562:3
    #4 0x55fdefcfc4fa in printing::PrintViewManagerBase::OnComposeDocumentDone(...) chrome/browser/printing/print_view_manager_base.cc:577:7
    ...

previously allocated by thread T0 (chrome) here:
    #0 0x55fde7c9b45d in operator new(unsigned long)
    #1 0x55fdefcf885d in printing::PrintViewManagerBase::PrintDocument(...) gen/third_party/libc++/src/include/__memory/unique_ptr.h:756:26
    ...

SUMMARY: AddressSanitizer: heap-use-after-free chrome/browser/printing/print_job_worker_oop.cc:293:17 in printing::PrintJobWorkerOop::SpoolDocument()

The complete ASAN log is in issue_metafile_toctou/asan.log.

Credit

Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.

The original report as published on the Chromium issue tracker, by c6eed09fc8b174b0f3eebedcceb1e792. 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

The worker thread calls GetMetafile without holding the required lock, and the DidPrintDocument handler does not enforce single-use semantics, allowing the metafile to be replaced and destroyed while still in use.

Impact

A compromised renderer could crash the browser process; the text does not claim further impact such as code execution.

What the attacker needed

Compromised renderer; OOP printing enabled (Linux/macOS default); CUPS printer configured

How it was found

  1. Apply the provided patch that inserts a sleep between GetMetafile and the dereference to stabilise the race.
  2. Build Chromium with ASAN and launch it with kiosk-printing and a test page.
  3. The page calls window.print() after two seconds, and the renderer repeatedly sends DidPrintDocument every 500ms.
  4. The browser process crashes with a heap-use-after-free within roughly ten seconds.

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.

In out-of-process printing, the browser asks a separate worker thread to prepare a document for printing. The worker reads a pointer to a document object without locking it, and another part of the browser can free that object at the same time. This is a use-after-free: the worker then uses memory that has already been freed, which crashes the browser.

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 c6eed09fc8b174b0f3eebedcceb1e792

View all

52 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.