================================================================================ legitbiz[research] // advisory ================================================================================ id: LB-2026-010 // html-pdf-node target: html-pdf-node (all versions) (npm) type: Cross-Site Scripting & SSRF (CWE-79, CWE-918) severity: Critical (CVSS:3.1 9.8 - AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) channel: GitHub Issues / Coordinated Disclosure date: 2026-11-27 status: submitted / vendor notified researcher: legitbiz[research] -------------------------------------------------------------------------------- [01] // summary -------------------------------------------------------------------------------- html-pdf-node converts HTML content or web pages to PDF using Puppeteer. It contains two critical vulnerabilities: 1. Cross-Site Scripting (XSS): User-supplied HTML content is rendered directly  in a headless browser launched with --no-sandbox, executing arbitrary JavaScript. 2. Server-Side Request Forgery (SSRF): User-supplied URLs are navigated to via  page.goto(), allowing requests to internal networks or local file:// protocols. -------------------------------------------------------------------------------- [02] // root cause analysis (index.js) -------------------------------------------------------------------------------- In index.js, generatePdf() processes input options: If file.content is provided:  data = await inlineCss(file.content, {url:"/"});  const template = hb.compile(data, { strict: true });  const result = template(data);  await page.setContent(result, { waitUntil: 'networkidle0' }); The content is passed straight to page.setContent(), executing embedded scripts. If file.url is provided:  await page.goto(file.url, { waitUntil:[ 'load', 'networkidle0'] }); The URL is passed straight to page.goto() without validation, enabling internal network scans and cloud metadata extraction (e.g. 169.254.169.254). -------------------------------------------------------------------------------- [03] // proof of concept -------------------------------------------------------------------------------- const pdf = require('html-pdf-node'); // XSS PoC: const fileXSS = { content: '

PDF

' }; pdf.generatePdf(fileXSS, { format: 'A4' }); // SSRF PoC: const fileSSRF = { url: 'http://169.254.169.254/latest/meta-data/' }; pdf.generatePdf(fileSSRF, { format: 'A4' }); -------------------------------------------------------------------------------- [04] // impact assessment -------------------------------------------------------------------------------- * CVSS v3.1 Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (Score: 9.8 Critical) * Real-World Impact:  - XSS: Execution of JavaScript inside the server's headless browser. Because  Puppeteer is launched with --no-sandbox, this elevates the risk of complete  host container compromise.  - SSRF: Access to cloud infrastructure metadata, internal databases, microservices,  and reading local filesystem files via file:// URLs into generated PDFs. -------------------------------------------------------------------------------- [05] // remediation -------------------------------------------------------------------------------- 1. For XSS: Sanitize HTML using DOMPurify before calling page.setContent(). 2. For SSRF: Validate URLs against an allowlist. Block private/internal IP ranges  (RFC 1918, link-local 169.254.0.0/16) and disable non-HTTP protocols. 3. Remove --no-sandbox and isolate the PDF renderer in a dedicated sandbox container. ================================================================================