Live data from Hacker News

Convert potentially dangerous PDFs to safe PDFs

github.com

61–70 of 72 posts

Re: Convert potentially dangerous PDFs to safe PDFs

#61

I personally just upload them to google drive. It would be a serious pwn if they could somehow still do a compromise through google drive.

(disclaimer: one of the Dangerzone devs)

That's something I do from time to time as well. AFAIK Google Drive renders all documents on the server-side (which implicitly means that they don't trust the browser sandbox), so that's a reasonable price to pay for less privacy.

Dealing with sensitive documents though is another story, you just can't upload them to a third-party service. That's where projects like Dangerzone come into play.

Re: Convert potentially dangerous PDFs to safe PDFs

#63
post #22

A handy side use for this is compressing PDFs. For some reason, printing 1 page of an Excel or Word document to a PDF often gets up to around 4MB in size. Passing it through this compresses it quite well. Just ran a quick test: - 1-page Excel PDF export: 3.7MB - Processing with Dangerzone (OCR enabled): 131KB

I wonder if the Excel export is retaining a lot of document structure in the event that it's imported back into Excel again at a later point.

Fun trivia: XLSX, DOCX, PPTX are just XML files, you can rename them to ".XML" file extension, and open them in notepad to see their raw contents.

But you can use qpdf or PDFEdit to interpret a PDF's raw code.

https://stackoverflow.com/a/6562443

And thus, you can compare the raw XLSX (XML) vs raw PDF.

Re: Convert potentially dangerous PDFs to safe PDFs

#64
post #58

Is there some reason why just viewing the PDF with a FLOSS, limited PDF viewer (e.g. atril) would not accomplish the same level of safety? What can a "dangerous PDF" do inside atril?

(Hi, disclaimer: I'm one of the current dangerzone maintainers) That's a good question :-) Opening PDFs, or images, or any other document directly inside your machine, even with a limited PDF viewer, potentially exposes your environment to this document. The reason is that exploits in the image/font/docs parsing/rendering libraries can happen and are exploited in the wild. These exploits make it possible for an attac…

> The reason is that exploits in the image/font/docs parsing/rendering libraries can happen and are exploited in the wild.

Aren't risks similar when opening any untrusted web page in a browser?

The only difference is that browser sandbox and exploit mitigations are probably better than that of a PDF viewer.

Re: Convert potentially dangerous PDFs to safe PDFs

#65
post #56
post #12

Heh, I've seen this a bunch of times and it's of interest to me, but honestly? It's sooooo limiting by being an interface without a complementary command line tool. Like, I'd like to put this into some workflows but it doesn't really make sense to without using something like pyautogui. But maybe I'm missing something hidden in the documentation.

(Hi, dangerzone maintainer here) There is indeed a dangerzone-cli tool¹, and it should be made more visible. We plan on updating/consolidating our docs in the foreseeable future, to make things clearer. Also, plans are here to make it possible to use dangerzone as a library, which should help use cases like the one you mention. ¹ https://github.com/freedomofpress/dangerzone/blob/main/dange...

Incredible, thanks for sharing! Can't wait to use it for my pdf pipelines :)

Re: Convert potentially dangerous PDFs to safe PDFs

#66

Earlier quoted context omitted.

Canary traps have been popularized in a few works of fiction. Seems trivial to do in the modern era. The sophisticated version I heard is to make the differences in the white space between individual words/lines/wherever. [0] https://en.wikipedia.org/wiki/Canary_trap

> The sophisticated version I heard is to make the differences in the white space between individual words/lines/wherever. That would be a naive way to do it. Here is an example of a more sophisticated way: A canary trap is a (method, way) for (exposing, determining) an information leak by giving (different, differing) versions of a (sensitive, secret) (document, file) to each of (several, two or more) (suspects, per…

What makes it more sophisticated to use synonyms instead of whitespace?

It sounds like a lot more work for the same result, and now it's much more obvious to people that they have different versions.

And even in your short example, many of the supposed synonyms change the actual meaning. And one winds up being grammatically incorrect.

Re: Convert potentially dangerous PDFs to safe PDFs

#67
post #22

A handy side use for this is compressing PDFs. For some reason, printing 1 page of an Excel or Word document to a PDF often gets up to around 4MB in size. Passing it through this compresses it quite well. Just ran a quick test: - 1-page Excel PDF export: 3.7MB - Processing with Dangerzone (OCR enabled): 131KB

I don't know if I would do that.

The size is probably font embedding.

And then the OCR will probably not be 100% correct if you ever intend to copy-paste from it.

Re: Convert potentially dangerous PDFs to safe PDFs

#68
Could we make a method to sanitize PDF’s that preserves the metadata?

It would be better to strip active content like javascript and actions, without flattening the PDF and losing all the text data having the original text is better than sending it through ocr again.

Re: Convert potentially dangerous PDFs to safe PDFs

#69
I'd rather have 2 minimal (headless, no network, etc) virtual machines. One runs pandoc for the conversion and the other runs ghostscript on the result. Nowadays you can let a web browser run pretty much anything so you don't need to build a vm image anymore.

Re: Convert potentially dangerous PDFs to safe PDFs

#70

While useful it needs a big red warning to potential leakers. If they were personally served documents (such as via email, while logged in, etc) there really isn't much that can be done to ascertain the safety of leaking it. It's not even safe if there are two or more leakers and they "compare notes" to try and "clean" something for release. https://en.wikipedia.org/wiki/Traitor_tracing#Watermarking https://arxiv.org…

Wouldn't comparing between two downloads reveal if the files are watermarked immediately though. Especially the sentence or other steganographic watermarks embedded in the text itself should show up pretty clearly to a simple comparison.
Post reply on HN