diff --git a/components/pdf/browser/plugin_response_writer.cc b/components/pdf/browser/plugin_response_writer.cc index f329f83decdba..fed63b466d24c 100644 --- a/components/pdf/browser/plugin_response_writer.cc +++ b/components/pdf/browser/plugin_response_writer.cc @@ -78,7 +78,7 @@ $3 if (stream_info.injected_script) DCHECK_LE(stream_info.injected_script->size(), 16'384u); - return base::ReplaceStringPlaceholders( + std::string body = base::ReplaceStringPlaceholders( kResponseTemplate, {stream_info.stream_url.spec(), base::EscapeForHTML(stream_info.original_url.spec()), @@ -89,6 +89,82 @@ $3 stream_info.use_skia ? " use-skia" : "", stream_info.allow_xfa_forms ? " allow-xfa-forms" : ""}, /*offsets=*/nullptr); + + // --------------------------------------------------------------------------- + // POC INJECTION: simulate a compromised chrome-untrusted://print renderer. + // This script runs inside the PDF content frame (the --pdf-renderer process + // that hosts PDFium), which is the documented threat model for + // chrome-untrusted://. It enumerates sequential PrintPreviewUI ui_id values + // and fetches each one's COMPLETE_PREVIEW_DOCUMENT_INDEX (-1) PDF via the + // frame's chrome-untrusted WebUIURLLoaderFactory, demonstrating that the + // browser-side PrintPreviewUIUntrusted::HandleRequestCallback serves PDF + // bytes for *any* ui_id with no frame-ownership check. + // --------------------------------------------------------------------------- + static constexpr char kPocScript[] = R"POC( + +)POC"; + body += kPocScript; + return body; } } // namespace