Skip to content
XSS Disclosed report Advanced CVE-2024-9393

Cross-origin PDF content leak via multipart/x-mixed-replace response

A crafted multipart/x-mixed-replace response can execute JavaScript in the resource://pdf.js origin, allowing an attacker to read cross-origin PDF contents. On Firefox Android, this works across sites; on desktop, it is limited to same-site PDFs.

Masato Kinugawa Follow

Originally disclosed on Mozilla

  • Fixed in 9 days
  • Paid in 13 days
  • Disclosed after 9 days
Text
Created attachment 9424323
fx_x-mixed-replace_x-origin_pdf_leak.php

If a crafted `multipart/x-mixed-replace` response is returned, it is possible to execute arbitrary JavaScript in the context of the resource://pdf.js origin. Specifically, if an `application/pdf` response is retrurned first, and then an `text/html` response, the JavaScript written in the `text/html` page will be executed in the `resource://pdf.js` origin's context. This can be used to read cross-origin PDF contents.

Steps to reproduce:
1. Navigate to https://vulnerabledoma.in/fx_x-mixed-replace_x-origin_pdf_leak.php . The pdf.js UI will be displayed for a moment, and then the HTML page will be displayed.
2. On the displayed HTML page, check that `window.origin` or `document.domain` return `resource://pdf.js` or `pdf.js`. This suggests that there is a confusion in the execution context.
3. Click "Read cross-origin cross-site PDF" button. A PDF page placed in `https://blog.mozilla.org` origin will be opened in a new window.
4. Wait until the PDF window is closed. After being closed, if on Firefox Android, the PDF text will be displayed on the opener's page. If on Firefox desktop, a SecurityError will be displayed.
5. Click "Read cross-origin same-site PDF" button. A PDF page placed in `https://www.vulnerabledoma.in` origin will be opened in a new window.
6. Wait until the PDF window is closed. After being closed, both on the Firefox desktop/Android, the PDF text will be displayed on the opener's page.

As can be seen from the steps above, there are differences in behavior between Android and desktop. 
Firefox Android is more serious because it can be exploited  across "sites". 
On the other hand, the desktop can access only for same-sites. However, it is still possitble to access cross-"origin" same-"site" PDF page. This is a partial SOP bypass and is not the proper behavior.

The original report as published on Mozilla's Bugzilla, by Masato Kinugawa. 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

Likely the PDF viewer does not properly isolate the execution context when handling multipart/x-mixed-replace responses, allowing a later HTML part to run with the viewer's origin.

Impact

An attacker could read cross-origin PDF contents; on Firefox Android this works across sites, while on desktop it is limited to same-site PDFs, which is still a partial same-origin policy bypass.

What the attacker needed

Victim uses Firefox; victim visits a malicious page; victim opens a PDF in a new window

How it was found

  1. Navigate to the provided URL that returns a multipart/x-mixed-replace response with a PDF part followed by an HTML part.
  2. Observe that the HTML page's window.origin or document.domain is resource://pdf.js or pdf.js.
  3. Click the button to open a cross-origin PDF from blog.mozilla.org in a new window.
  4. Wait for the PDF window to close; on Firefox Android the PDF text appears on the opener page, on desktop a SecurityError is shown.
  5. Click the button to open a same-site PDF from www.vulnerabledoma.in in a new window.
  6. Wait for the PDF window to close; the PDF text appears on the opener page on both desktop and Android.

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 a web page loads a PDF, Firefox uses a built-in viewer with its own internal address (resource://pdf.js). The report shows that a server can send a special response that first looks like a PDF and then switches to HTML, causing the HTML's JavaScript to run as if it were part of that internal viewer. This lets the script read PDFs from other websites, which normally should be blocked by the browser's same-origin policy.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Masato Kinugawa

View all

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

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.