Claude MCP skill SSRF via server-side screenshot and OpenGraph preview fetching in skill dashboards — SA-SKL-SSRF16
Modern MCP skill dashboards enrich skill listings with server-side media: README OpenGraph images are fetched and cached, screenshot services generate dashboard preview images from URLs, skill badges are fetched and embedded in PDF reports, and audit comment threads unfurl links to show previews. Each of these features requires the server to make an outbound HTTP request to a URL that — directly or indirectly — originates from attacker-controlled input: skill metadata on GitHub, a user-supplied dashboard URL, a skill's badge URL in its manifest, or a URL typed into an audit comment. Without SSRF validation on every outbound fetch path, an attacker can route these server-side requests to internal infrastructure. SA-SKL-SSRF16 covers four SSRF vectors in MCP skill preview and media-fetching code paths.
og:image URL server-side from the skill's GitHub README metadata — attacker publishes a skill with og:image=http://169.254.169.254/latest/meta-data/iam/security-credentials/role; server fetches AWS instance metadata and may log or display IAM credentials in the previewpuppeteer.page.goto(req.query.url) without IP validation; attacker submits http://169.254.169.254/ or http://10.0.0.1/admin as the preview URL; Puppeteer fetches internal services and returns rendered HTML to the attackerhttp://prometheus:9090/metrics or other internal monitoring endpoint; server fetches internal service response and embeds it in the PDFfetch(url); no SSRF validation; attacker posts a comment with an internal Redis or database health URL; server fetches the internal endpoint to generate a preview cardSSRF16-001 — og:image URL from skill README fetched server-side
Skill listing dashboards often display a preview image sourced from the skill repository's OpenGraph metadata. The server fetches the skill's GitHub README page, parses the og:image meta tag, and fetches that image URL server-side to cache it. An attacker who publishes a skill controls the GitHub repository and can set the OpenGraph image URL to any value — including the AWS EC2 instance metadata endpoint. When the skill is indexed by the platform, the server fetches that URL and the metadata response (which may contain IAM role credentials) is received by the server.
// VULNERABLE — SSRF16-001
// og:image URL from skill README fetched without SSRF validation.
// Attacker skill repo has in README:
// <meta property="og:image" content="http://169.254.169.254/latest/meta-data/iam/security-credentials/role" />
// Server fetches the og:image URL — receives IAM credentials in response body.
import * as cheerio from 'cheerio';
async function indexSkillPreview(githubReadmeUrl) {
const readmePage = await fetch(githubReadmeUrl);
const html = await readmePage.text();
const $ = cheerio.load(html);
const ogImage = $('meta[property="og:image"]').attr('content');
if (ogImage) {
// VULNERABLE: ogImage is from attacker-controlled README metadata — could be 169.254.169.254
const imageResponse = await fetch(ogImage);
const imageBuffer = await imageResponse.arrayBuffer();
await savePreviewImage(githubReadmeUrl, Buffer.from(imageBuffer));
}
}
// FIXED — SSRF16-001
// Fix 1: Validate og:image URL against SSRF allowlist before fetching.
// Fix 2: Allowlist scheme (https only) + resolve DNS + block RFC1918 ranges.
// Fix 3: Set short fetch timeout — if AWS metadata endpoint responds, timeout catches it.
async function indexSkillPreview(githubReadmeUrl) {
const readmePage = await fetch(githubReadmeUrl, { signal: AbortSignal.timeout(10000) });
const html = await readmePage.text();
const $ = cheerio.load(html);
const ogImage = $('meta[property="og:image"]').attr('content');
if (!ogImage) return;
// FIX 1 + 2: Validate og:image URL against SSRF allowlist before fetching
try {
await validateUrlForSsrf(ogImage);
} catch (e) {
console.warn('og:image URL failed SSRF validation:', e.message);
return; // Skip this skill's preview — don't fetch the blocked URL
}
// FIX 3: Short timeout — defense-in-depth against slow internal responses
const imageResponse = await fetch(ogImage, { signal: AbortSignal.timeout(5000) });
const imageBuffer = await imageResponse.arrayBuffer();
await savePreviewImage(githubReadmeUrl, Buffer.from(imageBuffer));
}
Detection: SkillAudit's SSRF scanner traces data flow from external metadata sources (GitHub README, npm registry, skill manifests) through any fetch() or HTTP client call. It flags cases where URLs extracted from these sources are used as fetch targets without an SSRF validation step.
SSRF16-002 — Puppeteer screenshot service with unvalidated URL
Screenshot services that use Puppeteer or Playwright to render a URL and return a screenshot image are common in developer tool dashboards. The URL is usually supplied by the user as a query parameter. Puppeteer's page.goto(url) makes an HTTP request from the server-side, which means it can reach internal services on the same network. Without SSRF validation — specifically DNS-based IP validation before the goto() call — the attacker can submit any URL, including http://169.254.169.254/ for AWS metadata, http://localhost:8080/ for a local admin interface, or any RFC1918 internal service. Puppeteer renders the response and returns the HTML content or screenshot to the attacker.
// VULNERABLE — SSRF16-002
// Puppeteer screenshot service with user-supplied URL — no IP validation.
// Attacker submits: GET /api/screenshot?url=http://169.254.169.254/
// Puppeteer renders the AWS metadata page and returns it as a screenshot image.
import puppeteer from 'puppeteer';
app.get('/api/screenshot', requireAuth, async (req, res) => {
const { url } = req.query;
if (!url) return res.status(400).json({ error: 'URL required' });
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// VULNERABLE: page.goto() with unvalidated user URL — renders internal services
await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 });
const screenshot = await page.screenshot({ type: 'png' });
await browser.close();
res.setHeader('Content-Type', 'image/png');
res.send(screenshot);
});
// FIXED — SSRF16-002
// Fix 1: DNS-based IP validation before page.goto() — block RFC1918, loopback, link-local.
// Fix 2: Use Puppeteer request interception to block any navigation to private IPs at render time.
// Fix 3: Allowlist URL scheme to https only — block http, file, data, javascript schemes.
import dns from 'dns/promises';
import puppeteer from 'puppeteer';
async function validateUrlForSsrf(urlString) {
const url = new URL(urlString); // throws on invalid URL
if (url.protocol !== 'https:') {
throw new Error('Only HTTPS URLs are allowed for screenshots');
}
const ipv4s = await dns.resolve4(url.hostname).catch(() => []);
for (const ip of ipv4s) {
if (isPrivateIP(ip)) {
throw new Error(`URL resolves to private IP: ${ip}`);
}
}
}
app.get('/api/screenshot', requireAuth, async (req, res) => {
const { url } = req.query;
// FIX 1: DNS-based SSRF validation before launching browser
try {
await validateUrlForSsrf(url);
} catch (e) {
return res.status(400).json({ error: 'URL not allowed: ' + e.message });
}
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// FIX 2: Intercept all requests inside Puppeteer — block private IP navigations
await page.setRequestInterception(true);
page.on('request', async (request) => {
try {
await validateUrlForSsrf(request.url());
request.continue();
} catch {
request.abort('blockedbyclient');
}
});
try {
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
const screenshot = await page.screenshot({ type: 'png' });
res.setHeader('Content-Type', 'image/png');
res.send(screenshot);
} finally {
await browser.close();
}
});
SSRF16-003 — Skill badge SVG fetched server-side from manifest URL
Skills can include badge URLs in their manifests (e.g., CI status badges, test coverage badges) for display in audit reports. When generating a PDF audit report, the platform fetches these badge SVGs server-side to embed them. If the badge URL in the manifest is not validated before fetching, an attacker can set it to an internal monitoring endpoint like Prometheus's /metrics, Grafana's /api/health, or the internal Redis INFO endpoint. The server fetches the internal service response and embeds its content in the generated PDF, which is then delivered to the attacker.
// VULNERABLE — SSRF16-003
// Badge URL from skill manifest fetched server-side without SSRF validation.
// Attacker skill manifest has: { "badgeUrl": "http://prometheus:9090/metrics" }
// PDF generation fetches that URL — Prometheus metrics embedded in PDF.
async function generateAuditPdf(audit) {
const skill = await getSkill(audit.skillId);
const manifest = skill.manifest;
if (manifest.badgeUrl) {
// VULNERABLE: badge URL from skill manifest — could be internal endpoint
const badgeResponse = await fetch(manifest.badgeUrl, { timeout: 5000 });
const badgeSvg = await badgeResponse.text();
// embeds badgeSvg content into PDF — internal metrics text in PDF body
await embedBadgeInPdf(badgeSvg);
}
}
// FIXED — SSRF16-003
// Fix: Allowlist badge URL to known badge services only (shields.io, badgen.net, img.shields.io).
// Known badge services are public CDNs — no need to support arbitrary URLs.
const BADGE_ALLOWLIST = new Set([
'shields.io', 'img.shields.io', 'badgen.net', 'flat.badgen.net',
'codecov.io', 'coveralls.io', 'travis-ci.com', 'github.com',
]);
function isBadgeUrlAllowed(urlString) {
try {
const url = new URL(urlString);
if (url.protocol !== 'https:') return false;
return BADGE_ALLOWLIST.has(url.hostname);
} catch {
return false;
}
}
async function generateAuditPdf(audit) {
const skill = await getSkill(audit.skillId);
const manifest = skill.manifest;
if (manifest.badgeUrl) {
// FIX: Allowlist badge URL to known badge CDNs only
if (!isBadgeUrlAllowed(manifest.badgeUrl)) {
console.warn('Badge URL not in allowlist, skipping:', manifest.badgeUrl);
return;
}
const badgeResponse = await fetch(manifest.badgeUrl, {
signal: AbortSignal.timeout(5000),
headers: { 'Accept': 'image/svg+xml' },
});
// FIX: Validate Content-Type — reject non-SVG responses
const ct = badgeResponse.headers.get('content-type') || '';
if (!ct.includes('svg')) return;
const badgeSvg = await badgeResponse.text();
await embedBadgeInPdf(badgeSvg);
}
}
SSRF16-004 — Link unfurl preview fetches comment URLs server-side
Audit collaboration features often include link unfurl previews: when a user posts a URL in an audit comment, the platform fetches that URL server-side to generate a title/image preview card. If the URL from the comment body is passed directly to fetch() without SSRF validation, an attacker can post a comment with an internal service URL and the preview fetcher will make a request to that internal endpoint on behalf of the attacker. The preview card may render metadata from the internal service response, or the attacker may observe timing differences that confirm the internal service is reachable.
// VULNERABLE — SSRF16-004
// Link unfurl fetches URL from comment body without SSRF validation.
// Attacker posts comment with URL: http://redis:6379/ or http://internal-db:5432/
// Unfurl fetcher makes HTTP request to internal service — timing + response leaks service info.
async function unfurlLinkPreview(url) {
// VULNERABLE: url from comment body — could be any internal service
const response = await fetch(url, { timeout: 5000 });
const html = await response.text();
const title = extractTitle(html);
const image = extractOgImage(html);
return { title, image, url };
}
// FIXED — SSRF16-004
// Fix 1: Validate URL against SSRF blocklist before fetching.
// Fix 2: Set short timeout (3s) — fast-fail on slow internal responses.
// Fix 3: Block redirects to RFC1918 — prevent open-redirect SSRF chaining.
// Fix 4: Only follow redirects that stay on the same public host.
async function unfurlLinkPreview(url) {
// FIX 1: SSRF validation — block RFC1918, loopback, link-local
try {
await validateUrlForSsrf(url);
} catch (e) {
return null; // Silently skip unfurl for blocked URLs
}
// FIX 2: Short timeout
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
try {
const response = await fetch(url, {
signal: controller.signal,
// FIX 3: Block redirects — manually handle to validate redirect destination
redirect: 'manual',
});
// FIX 4: If redirect, validate redirect destination before following
if (response.status >= 300 && response.status < 400) {
const location = response.headers.get('location');
if (!location) return null;
try {
await validateUrlForSsrf(location);
} catch {
return null; // Redirect to private IP — block
}
}
const html = await response.text();
return { title: extractTitle(html), image: extractOgImage(html), url };
} catch {
return null;
} finally {
clearTimeout(timeout);
}
}
Detection: SkillAudit scans for fetch(), axios.get(), got(), page.goto(), and other HTTP client calls where the URL argument traces back to: external metadata sources (GitHub README og:image, npm manifest fields), user-supplied query parameters or request body fields, or comment/annotation content fields — without an intervening SSRF validation call.
Summary — SA-SKL-SSRF16 at a glance
| Pattern | Root cause | Fix | Severity |
|---|---|---|---|
| SSRF16-001 | og:image URL from skill README metadata fetched server-side without SSRF validation; attacker sets URL to 169.254.169.254; IAM credentials received | Validate og:image URL with DNS IP check + RFC1918 blocklist before fetching; HTTPS only; short timeout | Critical |
| SSRF16-002 | Puppeteer page.goto(req.query.url) without IP validation; renders internal services and returns HTML/screenshot to attacker | DNS IP validation before goto(); Puppeteer request interception to block private IPs; HTTPS only | Critical |
| SSRF16-003 | Badge URL from skill manifest fetched server-side for PDF embedding; attacker sets URL to internal Prometheus or Redis endpoint; response embedded in PDF | Allowlist badge URL to known badge CDNs (shields.io, badgen.net); validate Content-Type: image/svg+xml in response | High |
| SSRF16-004 | Link unfurl preview fetches URL from comment body; no SSRF validation; attacker posts internal service URL; server probes internal endpoint | SSRF validation before fetch; 3s timeout; redirect: 'manual' with redirect destination validation | High |
Does your MCP skill's preview and media fetching code validate URLs against SSRF attacks?
SkillAudit scans for server-side fetch calls on URLs from external metadata sources, user-supplied preview URLs, skill manifest badge URLs, and comment body links — before an attacker routes your preview fetcher to your internal infrastructure.
Audit your MCP skill →