URL to PDF safely: why the renderer blocks internal addresses
A URL-to-PDF service runs a browser on your behalf, which makes it an SSRF target. How internal-address attacks work and how the JustAPI renderer stops them.
A URL-to-PDF service opens any page you ask for in a real browser, on a server inside a cloud network. That is exactly what an attacker wants. Server-side request forgery (SSRF) against HTML renderers is one of the most reported bug classes in PDF services, and it is why the HTML to PDF API refuses some URLs that look harmless.
How the attack works
The attacker does not ask for http://169.254.169.254/ directly; any service checks that. They use one of these:
- An iframe or image in HTML.
<iframe src="http://169.254.169.254/latest/meta-data/">inside the HTML you send. The PDF then shows the cloud metadata, sometimes including credentials. - A redirect. A public URL that answers
302to an internal address. - DNS rebinding. A hostname that resolves to a public IP when the service checks it, and to
127.0.0.1a second later when the browser connects. - Internal services on localhost, like an admin port or the serverless runtime API.
How the JustAPI renderer stops it
Checking the first URL is not enough, so the renderer checks every request the page makes:
- Every request goes through a proxy we control. Chromium is started with a proxy for all traffic, including what loads inside iframes.
- The proxy resolves the name itself and refuses any private, loopback, link-local, metadata or other non-public address.
- It connects to the exact IP it checked, so a second DNS answer cannot change the destination.
- Only web schemes are allowed: http, https, data and blob.
file://and others are blocked. - WebRTC is kept off the network, so it cannot open direct connections around the proxy.
The first url you send is also checked by the API before the renderer starts, and a refused URL fails with invalid_source at no charge.
What this means for you
- Pages on the public internet render as normal.
- Images and fonts on private networks will be missing from the PDF. Host them publicly, or inline them as data URIs.
- To render a page behind a login, generate its HTML in your own backend and send
htmlinstead ofurl.
If you run your own renderer
Puppeteer or wkhtmltopdf on a server has none of this by default. At minimum, route the browser through an egress proxy that resolves and checks IPs, and block the metadata address at the network level.
You can see the behavior in the free HTML to PDF tool: an internal URL is refused with a clear message.