Readit News logoReadit News
jerrygenser · a year ago
daghamm · a year ago
Accepted answer:

"Potentially, there is a tiny possibility... Keep in mind, it's a web application, and worse it can do is XSS attack"

One sad thing about security is that everyone and their uncle is a security expert.

naberhausj · a year ago
That answer goes on to say,

"If you serve untrusted PDFs in a PDF viewer and you are hosting at your location, it is better be located at different origin than your main app, www.example.org vs pdfviewer.example.org."

My understanding is that this CVE is an XSS attack, so isn't this advice sound? The RCE portion of this CVE is for Election, where every XSS attack is twice as fun.

Is there something about his answer that is wrong that I don't see? I hardly think we can fault someone simply for having faith in the integrity of software that everyone else trusted until now.

baobabKoodaa · a year ago
What is wrong with that accepted answer?
Art9681 · a year ago
Another sad thing is that no matter the accolades of the "security expert", the truth is that they havent been "hacked" because they or their business has nothing of value to those skilled enough to take it. "I can" doesn't mean "I want to", or "it's worth our time". Which is to say, everyone is an expert, until they are not.

Deleted Comment

pixl97 · a year ago
That poor incorrect post in that thread from 2018.
naberhausj · a year ago
Like I asked the other person in this thread, what's wrong with that answer?

Not only does it correctly identify the attack vector of this CVE, but I think his advice on how to mitigate it is sound. Is there something I'm missing? The only flaw I see is that it doesn't consider the implications of using PDF.js in Electron.

tgsovlerkhgsel · a year ago
It's not even incorrect.

The option isn't supposed to allow XSS-by-design (which the original requester was worried about), the possibility of a vulnerability is mentioned, the impact of a vulnerability is correctly described (XSS not RCE or similar), and mitigations that would effectively limit the impact of such a vulnerability are presented (separate origin).

Deleted Comment

kibwen · a year ago
Arbitrary code execution, though only of Javascript, so (as far as the browser use case is concerned) the risk compared to visiting any website (other than the potential for XSS) is that the context that it's running in is slightly elevated (though still much less than having full control of your machine):

> PDF.js runs under the origin resource://pdf.js. This prevents access to local files, but it is slightly more privileged in other aspects. For example, it is possible to invoke a file download (through a dialog), even to “download” arbitrary file:// URLs. Additionally, the real path of the opened PDF file is stored in window.PDFViewerApplication.url, allowing an attacker to spy on people opening a PDF file, learning not just when they open the file and what they’re doing with it, but also where the file is located on their machine.

toxik · a year ago
If you can upload a PDF and have it served on the root domain, eg, gmail.com, then you can do session hijacking and other XSS. It’s actually pretty bad. XSS used to be thought of as “not that bad”, but today it is considered pretty bad.
kibwen · a year ago
Yes, I'm not here to downplay the severity of XSS. Rather, I'm trying to be specific about the potential attack vector here.

If you're just viewing a PDF using the built-in pdf.js in Firefox, then (AFAIK) it doesn't matter what site you downloaded it from, because pdf.js isn't running in the context of the website, so it doesn't have access to that site's locally-stored data (including cookies). Instead it's running in the origin mentioned above, with the accompanying concerns.

So the XSS (again, as far as a web browser is concerned) would be if the site itself is shipping pdf.js for viewing PDFs inside the webpage itself. As you suggest, Gmail lets you preview PDFs, so XSS would be a concern there, but only if Gmail is using pdf.js.

tgsovlerkhgsel · a year ago
How would serving the PDF on a sensitive origin help the attacker? Wouldn't they need to serve the vulnerable PDF viewer on a sensitive origin?
iudqnolq · a year ago
Wouldn't that take a separate vulnerability? This is why Google serves attachments off something like googleusercontent.com.
jeroenhd · a year ago
The risk is higher in Electron/Tauri applications, which often expose native code paths to the application Javascript, as the script executed is supposed to come exclusively from the application developers.

This too can be harderend against, but it's a significant attack vector in quite a few desktop applications if users don't update.

kyrra · a year ago
The impact here is XSS or possible RCE for electron.

> In applications that embed PDF.js, the impact is potentially even worse. If no mitigations are in place (see below), this essentially gives an attacker an XSS primitive on the domain which includes the PDF viewer. Depending on the application this can lead to data leaks, malicious actions being performed in the name of a victim, or even a full account take-over. On Electron apps that do not properly sandbox JavaScript code, this vulnerability even leads to native code execution (!). We found this to be the case for at least one popular Electron app.

plingbang · a year ago
I remember MS Teams opening various files within itself instead of launching an appropriate program. I wonder what they're using for rendering PDFs.
gostsamo · a year ago
At least edge uses a module from word as far as I know and I'd expect the same for teams. They likely are not affected.
Gare · a year ago
That's why I use MS Teams (on desktop) via browser only. Keeps it nicely sandboxed.
mattsan · a year ago
Haven't tested but I'm almost certain the Electron app they're talking about is VS Code. Wouldn't make sense for a code editor to sandbox extensions
notnullorvoid · a year ago
I don't believe they are talking about a VS Code extension embedding PDF.js but rather an Electron app that has PDF.js embedded by default. My guess is Slack.
eviks · a year ago
> The PDF format is famously complex. With support for various media types, complicated font rendering and even rudimentary scripting, PDF readers are a common target for vulnerability researchers.

So still no chance in the foreseeable future for this monstrous "paper-based" mockery of docs in a digital age to get phased out?

Dalewyn · a year ago
Paper is still very much a thing in business and office work. PDFs allowing a near perfect translation between computer monitor and paper is an absolutely critical piece of technological infrastructure.
pjmlp · a year ago
Sure, if you come up with something that covers all PS and PDF use cases.
niutech · a year ago
What about OpenXPS (ECMA-388)?
rrr_oh_man · a year ago
What's the alternative?
jl6 · a year ago
PDF/A. All the good bits of PDF (compatibility, standardization, encapsulation), without the worst bits (media extensions, JavaScript).

(Except PDF/A-4, which reintroduces JavaScript for some horrific reason).

jandrese · a year ago
Eps, but it is not much better.
jl6 · a year ago
Strict validation could theoretically have helped here, as /FontMatrix is required by the PDF spec to be an array of six numbers. The exploit string was syntactically valid but semantically invalid.

Unfortunately, applications that produce broken PDFs are rife, and Postel's law sets the expectation that we should consume garbage and be happy.

notnullorvoid · a year ago
Postel's law should not be applied so broadly, and certainly shouldn't be used as an argument against further validation of inputs.

Garbage inputs are the responsibility of the sender, not the receiver. You can and should accept a small margin of error in inputs where errors may logically appear, but if the receiver accepts too much error then it becomes responsible by creating a complicit norm. If the responsibility of error remains on the sender then introducing further validation is less likely to cause breakage in communication.

MartijnHols · a year ago
A good Content Security Policy [1] could prevent this as well as nullify the impact. If you're embedding a PDF in your app, you really should have one set up.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP

mrob · a year ago
Does setting pdfjs.enableScripting to false in about:config protect against this? IMO, permitting PDFs to run Javascript violates the Principle of Least Astonishment:

https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...

Common sense suggests PDFs are the digital equivalent of paper documents. Paper documents can't run Javascript, so PDFs shouldn't either.

jmull · a year ago
No. From the article:

> You might be surprised to hear that this bug is not related to the PDF format’s (JavaScript!) scripting functionality. Instead, it is an oversight in a specific part of the font rendering code.

It goes on to explain that pdfjs dynamically constructs and executes javascript functions as an optimization for rendering older fonts. Certain arguments pulled from the PDF were not escaped, validated, or delimited (the values were expected to be numbers), so you could inject arbitrary JS. (At least that's how I read it.)