XSS in PDF Viewer
An outdated version of PDF.js in the PDF viewer is vulnerable to CVE-2018-5158, allowing a malicious PDF to execute arbitrary JavaScript when opened. An attacker could run script in the context of the PDF viewer, though fetching further code was blocked by CORS.
- Triaged in 7 hours
- Fixed in 3 days
- Paid in 3 days
- Disclosed after 2 months
Summary by the researcher
You can find my full write-up at https://tripplyons.com/blog/nextcloud-bug-bounty
The report
An outdated version of PDF.js in use allows for the CVE-2018-5158 vulnerability.
When the payload PDF is shown in the supplied PDF viewer, it can execute arbitrary JavaScript.
I have tested the payload PDF, and it is working in the Safari 13.0.5 (the latest version) and Firefox 74.0 (the latest version). Although, it does not work in the latest version of Chrome.
I could not find a way to test it on the desktop client. I assume that it would use the system PDF viewer.
Modifying the payload to fetch other code was luckily blocked because of a CORS policy.
The payload is from https://bugzilla.mozilla.org/show_bug.cgi?id=1452075. I have also included the PDF in the attachments.
The payload can be seen in action by checking the JavaScript console. It says "Hello, this is code running in" followed by the path to file where the vulnerability is.
Impact
An attacker could execute arbitrary JavaScript code on a web browser when a PDF containing an exploit is opened.
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
Impact
An attacker could execute arbitrary JavaScript code on a web browser when a PDF containing an exploit is opened, though fetching other code was blocked by a CORS policy.
What the attacker needed
Victim opens a malicious PDF; PDF viewer uses vulnerable PDF.js
How it was found
- Open the malicious PDF in the supplied PDF viewer.
- Check the JavaScript console for the message indicating code execution.
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.
PDF.js displays PDF files in a web page. Because the version was old, a crafted PDF could run JavaScript in the browser. Further code loading was stopped by a CORS policy.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.