Recently I've been looking into PDF files security, specifically about malware exploiting vulnerabilities in PDF readers. I thought about one thing - does compressing PDF file (for example, by using qpdf) create as to speak "new" file (assuming it was infected before with JS, pdf viewer exploits etc) clean of these problems? Im asking because while Im somewhat aware creating new file (with Ghostscript for example) most likely would do that, but never really found out about simple compression of said file (GS doesn't do that as far as I know).

  • What "malware" you are talking about? Social engineering using PDF, embedded files (which need external activation to do harm), malware exploiting vulnerabilities in specific PDF readers, ... ? Commented Mar 23 at 21:00
  • Sorry for not being specific, I was asking about exploiting vulnerabilities in specific PDF readers.
    – Madzik
    Commented Mar 23 at 21:37

1 Answer 1


PDF level compression is only about reducing the size of the content, not about removing content. So it depends if the vulnerability was triggered by the content no matter how encoded/compressed it was or if it was triggered only with a specific form of encoding/compression (or no compression). The latter is likely the more rare kind of vulnerability, so in most cases compression probably does not make the PDF file sufficiently clean.

  • 1
    Thanks for explaining it in such straight-forward way.
    – Madzik
    Commented Mar 23 at 21:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .