URL-to-PDF and SSRF: how a PDF renderer becomes an attack surface
A renderer that fetches URLs can be pointed at your internal network. The attacks, the defences, and what to demand from a PDF API vendor.
Updated 31 August 2026
A URL-to-PDF endpoint is a web browser you let strangers drive. If that browser sits inside your network, it can be asked to open `http://169.254.169.254/` (cloud metadata), `http://localhost:8080/admin`, or a colleague's dashboard — and print what it sees into a PDF the attacker downloads.
The attack
- Direct: submit an internal URL
- Redirect: submit a public URL that 302s to an internal one
- DNS rebinding: a hostname that resolves publicly the first time and privately the second
- Injected HTML: an `
Defences that work
- Resolve the hostname and refuse private, loopback, link-local and metadata ranges — before every navigation, including redirects and subresources
- Run the browser on a host with no route to internal services; egress only
- Block `file://` and other non-http schemes
- Time out and cap the page size, so a slow endpoint cannot tie up a worker
- Never run the renderer with credentials or cookies of your own
What to ask a vendor
Whether they block private ranges on redirects, not just the initial URL. Whether the render hosts are isolated from their own infrastructure. Whether user HTML can reach internal addresses via subresources. PDFGeny checks every navigation request against the private-range list and renders on hosts that only see the public internet.
Try it: convert HTML to PDF in the browser, or get a free API key — 50 documents a month.
More guides
Writing HTML templates for PDF: a style guide (Jinja, Django, Handlebars)
Templates that render well as PDFs follow a few rules: fixed page geometry, no external state, defensive filters, print CSS. Examples in Jinja and Django syntax.
Issuing 5,000 course certificates in one afternoon
A spreadsheet of names, one landscape template, batch requests of 100, and signed links per student. The full workflow including naming, verification codes and delivery.
Generating receipts at checkout without slowing the checkout
The receipt PDF should never sit between the customer and the order confirmation. A pattern: confirm first, render asynchronously, attach when ready.
Why the PDF from headless Chromium differs from Print to PDF in the browser
Same engine, different output: viewport, print media, backgrounds, default margins, headless font rendering. A list of the differences and the option that fixes each.