Skip to content
CORS Disclosed report Advanced CVE-2018-5157

Race condition in PDF Viewer allows circumventing same-origin policy for PDF files

The PDF viewer's stream converter posted file data to any origin using a wildcard, so if the viewer was replaced by another document, that document received the PDF content. An attacker could retrieve PDF files accessible to the victim, such as intranet documents or private storage files.

Wladimir Palant Follow

Originally disclosed on Mozilla

  • Fixed in 16 days
  • Paid in 4 days
  • Disclosed after 16 days
Text
Created attachment 8963531
Proof of concept page

When a PDF file opens in the built-in PDF Viewer, the stream converter will retrieve the file data and post it as a message to the viewer (see https://dxr.mozilla.org/mozilla-central/rev/a456475502b80a1264642d9eaee9394a8fad8315/browser/extensions/pdfjs/content/PdfStreamConverter.jsm#605). When doing this, it specifies "*" as the recipient's origin. So if the PDF Viewer got replaced by another document in the meantime, that other document will receive the message.

Steps to reproduce:

1. Open the attached proof of concept page.
2. Enter the URL of a PDF file into the text field and click "Download"
3. Wait a bit.

When testing with https://www.microsoft.com/en-us/research/wp-content/uploads/2006/11/www2007.pdf, this page succeeds within a few seconds for me and displays the first 160 bytes of the PDF file. It does that by loading the PDF in a hidden frame first to make sure that it is cached. After that it will 
repeatedly load the PDF file in a frame, then replace the frame contents by about:blank after a random time interval.


I am not entirely sure why it doesn't work reliably with other PDF files for me, but with some tweaks to the timing it should be possible. So a malicious website should be able to retrieve PDF files in the background that only the website visitor can access. That might be documents on the intranet for example, or private documents on some storage service.

I tested with Firefox 59.0.2 and Firefox 61.0a1 (2018-03-28) nightly on Linux.

The original report as published on Mozilla's Bugzilla, by Wladimir Palant. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 PDF stream converter used a wildcard ('*') as the target origin when posting the PDF data, allowing any document that replaced the viewer to receive the message.

Impact

A malicious website could retrieve PDF files that only the visitor can access, such as intranet documents or private storage files, though the attack did not work reliably for all PDFs and required timing tweaks.

What the attacker needed

Victim visits a malicious page; victim has access to target PDF; timing must be right

How it was found

  1. Open the proof of concept page.
  2. Enter the URL of a PDF file into the text field and click 'Download'.
  3. Wait a bit.

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.

When you open a PDF in Firefox, a background script sends the PDF data to the viewer using a messaging system. The script used a wildcard to say 'any page can receive this message', which is unsafe. If an attacker can swap the viewer for their own page at the right moment, they can receive the PDF data and read files you have access to.

What is CORS?

A permissive cross-origin policy lets another site read responses with the user's credentials.

More by Wladimir Palant

View all

30 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.