Live data from Hacker News

Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

github.com

31–40 of 60 posts

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#32

This kind of makes me wonder why PDFs can even act maliciously in the first place. Why does it have the ability to do these things?

I think it's just that Adobe wanted to add more features, even ones that have no place in the PDF format.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#33

This kind of makes me wonder why PDFs can even act maliciously in the first place. Why does it have the ability to do these things?

PDF derives from PostScript which is a full-blown programming language so it's an "original sin" either way.

Then over time Adobe added a number of interactive (forms), multimedia and rich media (embedded JS) features, leading to even more vectors.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#34

All because Microsoft, the company that made formated text dangerous.

When one enables functionality, this results in both good and bad behaviour.

Microsoft did not build the guns, it made engineering possible. Some engineers are bad. But a lot are good.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#35
post #20

Earlier quoted context omitted.

If I understand this correctly, a link wouldn't survive this as the pdf is turned into images and then those images back into a pdf. So it's essentially like a scan of very high quality. What you would end up with is an image that looks like a link but would not be clickable.

> Dangerzone can optionally OCR the safe PDFs it creates, so it will have a text layer again I'm not completely sure, but wouldn't this parse links and make them accessible again, possibly even clickable?

A links displayed text and its destination URL are not necessarily the same. Rendering the document to a bitmap then OCRing that would get the display text rather than the URL. I would think that it would be normal for a malicious URL to be obscured with an innocent looking display text.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#36
Obligatory humblebrag/shameless plug for my open source PDF(+ other docs) to Image converter, which runs as a web app. It's self hosted open source (but easiest to run on FreeBSD). Uses Ghostscript/OpenOffice under the hood:

https://github.com/dosyago/p2..git

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#37

Useful tool -- it's trivial to make a RAT bypass chat/email .doc/.PDF attachments. I don't open any files on my PC from people I don't personally know -- use webviewers.

FWIW... you probably shouldn’t even trust your contacts. People get phished all the time.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#38
post #2

This is definitely a good brute force strategy I ... think there’s another technique that relies a bit on trusting the printing drivers to do the right thing, where you can tell Ghostscript to print your document, and target another PDF. This should at least remove interactive components in a PDF

Be very wary of exposing Ghostscript to untrusted data.

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#39
In (1) the author use as a cv a pdf that is also a bootloader , and in the comments it seems that he has improved the code. I wonder if he could render dangerzone as futile.

(1) https://news.ycombinator.com/item?id=19344146

Edited: Added in the comments of that post there is a reference to pocorgtfo16.pdf: is valid as a PDF document, a ZIP archive, and a Bash script that runs a Python webserver which hosts Kaitai Struct’s WebIDE which, allows you to view the file’s own annotated bytes. The zip archive has further resources to insane reversing deep dives, code to study and more.

[2] https://www.alchemistowl.org/pocorgtfo/:w

Re: Dangerzone: Convert potentially dangerous PDFs, documents, or images to safe PDF

#40
It's nice that PDF security is getting a bit more attention, but there are a number of things that this approach will trash, for instance, I don't have high hopes for the accessibility of the resulting PDF. (edit: and needless to say, any software in your pipeline which does full interpretation of an untrusted file will itself become the target for attacks, so this is only a useful tool if it is run in an extremely restricted environment)

I for one have been looking a lot into PDF/A for security. PDF/A is really meant for archival, but as a side effect has disallowed an awful lot of weird PDF features which are a security nightmare and pdf readers tend to implement badly/buggily. PDF/A-1 for example, the strictest level, disallows JPEG2000, TIFF, JavaScript, PostScript, embedded files... (PDF/A-3, FWIW is essentially useless from this angle, because they decided to allow arbitrary embedded files, so a valid PDF/A-3 could have pretty much anything in it).

There now exists a good PDF/A validator (https://verapdf.org/) which can be used to ensure PDFs conform to the standard, but of course, won't fix them if they're not.

PDF/A has an interesting implementation detail however - compliant PDF readers are supposed to automatically "turn off" non-PDF/A features when they encounter a PDF which declares itself as a particular PDF/A variant (even if it then goes on to attempt to use non-compliant features), which would hopefully prevent dangerous sections from being decoded and avoid exploitation). Another interesting feature of PDF is its appendable nature, which might raise the possibility of being able to "declare" an arbitrary PDF as PDF/A by simply appending an extra section to it, hopefully rendering it less harmful (though possibly at the expense of it appearing to have missing content when rendered).

Post reply on HN