PDF / Document Injection
Overview
PDF generators that include user-controlled HTML or data can be exploited:
- HTML to PDF injection: Injecting
<script>or<link>tags that read local files via PDF rendering engine (wkhtmltopdf, Puppeteer) - JavaScript in PDF: PDF actions that execute JavaScript in Adobe Reader
- Formula injection in generated Excel: See CSV Injection
wkhtmltopdf and similar tools can read local files: <img src="file:///etc/passwd"> in the input HTML.
Remediation
- HTML-encode all user input before HTML-to-PDF conversion
- Use
--no-local-file-accessflag with wkhtmltopdf - Use sandboxed PDF generation with no filesystem access