Live data from Hacker News

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

github.com

21–30 of 60 posts

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

#21
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

It's definitely brute force, in that it's the equivalent of printing a document onto paper and then scanning it back in. This "flattening" is highly effective at sanitising, but also removes all the semantic content in the process; the output should be several times larger than the input (and if it isn't, then it's an indication that something very suspicious was in the input....)

Indeed, I was hoping for something smarter, that would remove only the "risky" bits of PDF, but keep the overall structure (and size).

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

#22

Earlier quoted context omitted.

I used to deal with PDF at my day job. Among all the tools we use in production, Ghostscript probably has the most 0 day. Thankfully we're paranoid about security and run everything in sandbox. Still it's no fun getting nagged by security to upgrade our Ghostscript version.

It's funny how they all seem to have been found by one person (Tavis Ormandy) too. It's like the setup and PostScript standard are so baroque that only one human understands them, and that human takes a week or so every year or two to research and drop another 0day. https://bugs.chromium.org/p/project-zero/issues/detail?id=16...

[deleted]

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

#23
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?

Maybe use pdftotext wrapper to extract text along side the image based pdf.

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

#24
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

It's definitely brute force, in that it's the equivalent of printing a document onto paper and then scanning it back in. This "flattening" is highly effective at sanitising, but also removes all the semantic content in the process; the output should be several times larger than the input (and if it isn't, then it's an indication that something very suspicious was in the input....)

IIRC this is also how Firefox is doing it for its pdf.js print feature: https://github.com/mozilla/pdf.js/blob/master/web/pdf_print_...

Which is why when you print a PDF from Firefox, it doesn't look very nice. But it's safer than sending unsanitized PDFs to printers.

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

#25

Earlier quoted context omitted.

I used to deal with PDF at my day job. Among all the tools we use in production, Ghostscript probably has the most 0 day. Thankfully we're paranoid about security and run everything in sandbox. Still it's no fun getting nagged by security to upgrade our Ghostscript version.

It's funny how they all seem to have been found by one person (Tavis Ormandy) too. It's like the setup and PostScript standard are so baroque that only one human understands them, and that human takes a week or so every year or two to research and drop another 0day. https://bugs.chromium.org/p/project-zero/issues/detail?id=16...

Honestly it is starting to feel like most major exploits in most major software/platforms are being found by Tavis Ormandy these days. He's really good at what he does.

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

#27
post #16

Very nice but fyi: most malicious pdf just contains links to something else,usually shortlinks. Social engineering is hard to mitigate.

A PDF smartform can run ActionScript.

Fortunately smart forms require Adobe Viewer, and there's an approval step (similar to agreeing to Excel macros), but after that it can do whatever the hell it likes.

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

#28

Earlier quoted context omitted.

I used to deal with PDF at my day job. Among all the tools we use in production, Ghostscript probably has the most 0 day. Thankfully we're paranoid about security and run everything in sandbox. Still it's no fun getting nagged by security to upgrade our Ghostscript version.

It's funny how they all seem to have been found by one person (Tavis Ormandy) too. It's like the setup and PostScript standard are so baroque that only one human understands them, and that human takes a week or so every year or two to research and drop another 0day. https://bugs.chromium.org/p/project-zero/issues/detail?id=16...

Well, Tavis is one of the infosec superstars, the amount of stuff he comes up with is amazing.
Post reply on HN