Claude MCP skill SSRF — external documentation and README sync endpoints

SA-SKL-SSRF37 documents four SSRF vulnerabilities in MCP skill registry external documentation and README sync endpoints. A documentation sync endpoint that fetches a user-supplied docsUrl can be pointed at the EC2 instance metadata service, returning IAM credentials that are stored as documentation and displayed publicly; a README image proxy that fetches user-supplied imageUrl values can be redirected to internal Prometheus metrics endpoints, persisting metric data as cached image bytes; a changelog sync endpoint that follows HTTP redirects enables an attacker-controlled CNAME chain to reach the internal Consul HTTP API; and a skill version check endpoint that pings a user-supplied updateUrl stores etcd key-value range responses as version metadata.

Critical SSRF37-001 — documentation sync fetches user-supplied docsUrl; attacker sets to 169.254.169.254/latest/meta-data/iam/security-credentials/; EC2 IAM credentials in response stored as skill documentation and displayed publicly to all registry users
High SSRF37-002 — README image proxy fetches user-supplied imageUrl to cache badge images; attacker sets to internal Prometheus :9090/metrics; Prometheus metric exposition text stored as cached image bytes and served to all skill page viewers
High SSRF37-003 — changelog sync fetches user-supplied changelogUrl with redirect: 'follow'; attacker controls domain with CNAME to consul.internal; redirect chain reaches consul:8500/v1/kv; KV data stored as parsed changelog entries
High SSRF37-004 — version check pings user-supplied updateUrl to detect new skill versions; attacker sets to etcd:2379; etcd /v3/kv/range response stored as skill version metadata and returned to any registry viewer

SSRF37-001 (Critical): Documentation sync SSRF leaks EC2 IAM credentials stored as public skill docs

MCP skill registries frequently allow skill authors to supply a docsUrl pointing to external documentation hosted on GitHub Pages, ReadTheDocs, or similar services. The registry server fetches and indexes this documentation to power the search interface and render skill detail pages. When the fetch is performed without restricting the target to known documentation hostnames or blocking private IP ranges, an attacker who registers a skill can set docsUrl to the EC2 instance metadata service endpoint at http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name. The metadata service returns a JSON object containing the instance role's AccessKeyId, SecretAccessKey, and Token.

The critical amplifier in this finding is that the fetched content is stored as skill documentation and rendered publicly on the skill detail page. Any user browsing the skill registry can read the IAM credentials without authentication. These credentials grant whatever permissions the EC2 instance role carries — often broad AWS permissions needed to operate the registry infrastructure. The attack requires only the ability to register a skill (which is typically open to all registered users) and produces a persistent credential exposure that persists until the documentation is re-synced or the skill is deleted. CVSS 9.8 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H).

// VULNERABLE — documentation sync fetches user-supplied docsUrl without IP restriction
// File: services/docs-sync.js

const fetch = require('node-fetch');

async function syncSkillDocumentation(skillId, docsUrl) {
  // VULNERABILITY: no hostname allowlist; no private IP block
  // Attacker sets docsUrl to http://169.254.169.254/latest/meta-data/iam/security-credentials/role
  const response = await fetch(docsUrl, {
    timeout: 10000,
    // redirect: 'follow' by default — attacker can also use redirect chains
  });

  const content = await response.text();

  // IAM credentials in content are now stored as skill documentation
  // and rendered publicly on the skill detail page
  await db.query(
    'UPDATE skills SET docs_content = $1, docs_synced_at = NOW() WHERE id = $2',
    [content, skillId]
  );
}

Fix: Implement a hostname allowlist of known documentation CDN hostnames (raw.githubusercontent.com, docs.github.com, readthedocs.io, pages.github.io). After DNS resolution of any user-supplied URL, check the resulting IP address against RFC 1918 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), link-local range (169.254.0.0/16), and loopback (127.0.0.0/8). Set redirect: 'error' to prevent redirect-based bypass. Parse the fetched content as CommonMark markdown and return only the parsed AST — never store the raw response body.

// FIXED — hostname allowlist; DNS-based private IP block; CommonMark parse only
// File: services/docs-sync.js

const fetch = require('node-fetch');
const dns = require('dns').promises;
const { isPrivateIp } = require('./utils/ip-validation');
const { unified } = require('unified');
const remarkParse = require('remark-parse');
const remarkHtml = require('remark-html');

const DOCS_HOSTNAME_ALLOWLIST = new Set([
  'raw.githubusercontent.com',
  'docs.github.com',
  'readthedocs.io',
  'pages.github.io',
  'cdn.jsdelivr.net',
]);

async function syncSkillDocumentation(skillId, docsUrl) {
  let parsed;
  try { parsed = new URL(docsUrl); } catch {
    throw new Error('Invalid docsUrl');
  }

  // Hostname allowlist — only known documentation CDNs
  if (!DOCS_HOSTNAME_ALLOWLIST.has(parsed.hostname)) {
    throw new Error(`docsUrl hostname not allowed: ${parsed.hostname}`);
  }

  // DNS resolution check — block private IP ranges after resolution
  const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
  for (const ip of addresses) {
    if (isPrivateIp(ip)) throw new Error(`docsUrl resolves to private IP: ${ip}`);
  }

  const response = await fetch(docsUrl, {
    timeout: 10000,
    redirect: 'error',  // no redirect following
    size: 500000,       // 500 KB max
  });

  const rawMarkdown = await response.text();

  // Parse as CommonMark — strips any embedded HTML or non-text content
  const htmlContent = await unified()
    .use(remarkParse)
    .use(remarkHtml, { sanitize: true })
    .process(rawMarkdown);

  await db.query(
    'UPDATE skills SET docs_content = $1, docs_synced_at = NOW() WHERE id = $2',
    [String(htmlContent), skillId]
  );
}

SSRF37-002 (High): README image proxy SSRF to internal Prometheus metrics stored as cached image bytes

To improve README rendering performance and avoid hotlinking third-party image hosts, MCP skill registries often implement a server-side image proxy that fetches badge images (build status, coverage percentage, version indicators) from external URLs and caches them locally. When this proxy fetches user-supplied imageUrl values without validating the target hostname or the response Content-Type, an attacker can point it at an internal Prometheus metrics endpoint.

Prometheus exposes metrics in a text-based exposition format at http://prometheus-host:9090/metrics. This format is a valid response to an HTTP GET request. The image proxy stores the response body as cached bytes associated with the image URL key. Any skill page viewer's browser subsequently receives the Prometheus metrics text when it requests the cached image URL — revealing application-level metrics, infrastructure health data, endpoint latency histograms, database connection pool statistics, and potentially secret values stored as label values in custom metrics. Because the data is served from the registry's own CDN or cache, it bypasses browser same-origin restrictions and CSP policies that might otherwise prevent the data from being read. CVSS 7.5 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).

// VULNERABLE — image proxy fetches user-supplied imageUrl without Content-Type validation
// File: routes/image-proxy.js

const fetch = require('node-fetch');
const path = require('path');

router.get('/readme-image', async (req, res) => {
  const { imageUrl } = req.query;

  // VULNERABILITY: no hostname allowlist; no Content-Type validation
  // Attacker sets imageUrl to http://prometheus.internal:9090/metrics
  // Response is stored as cached image; Prometheus metrics served to all viewers
  const response = await fetch(imageUrl, { timeout: 5000 });
  const buffer = await response.buffer();

  // Cached without Content-Type check — Prometheus text stored as "image"
  const cacheKey = `img:${Buffer.from(imageUrl).toString('base64')}`;
  await redis.set(cacheKey, buffer, 'EX', 3600);

  // Served to any browser requesting this endpoint
  res.set('Content-Type', response.headers.get('content-type') || 'image/png');
  res.send(buffer);
});

Fix: Allowlist known badge CDN hostnames (img.shields.io, badges.github.io, codecov.io). After fetching, validate that the response Content-Type starts with image/ before caching or serving; reject any response with a text or JSON content type. Apply a maximum response size limit (e.g., 2 MB). Implement a DNS-based private IP block applied before the fetch. Consider deriving image URLs from registry metadata (e.g., the GitHub API for status badges) rather than accepting arbitrary user-supplied URLs.

// FIXED — hostname allowlist; Content-Type validation; DNS private-IP block
// File: routes/image-proxy.js

const fetch = require('node-fetch');
const dns = require('dns').promises;
const { isPrivateIp } = require('./utils/ip-validation');

const IMAGE_HOSTNAME_ALLOWLIST = new Set([
  'img.shields.io',
  'badges.github.io',
  'codecov.io',
  'raw.githubusercontent.com',
  'api.travis-ci.com',
]);

router.get('/readme-image', async (req, res) => {
  const { imageUrl } = req.query;
  if (!imageUrl) return res.status(400).end();

  let parsed;
  try { parsed = new URL(imageUrl); } catch {
    return res.status(400).json({ error: 'Invalid imageUrl' });
  }

  if (!IMAGE_HOSTNAME_ALLOWLIST.has(parsed.hostname)) {
    return res.status(403).json({ error: 'Image hostname not allowed' });
  }

  const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
  for (const ip of addresses) {
    if (isPrivateIp(ip)) return res.status(403).json({ error: 'Private IP blocked' });
  }

  const response = await fetch(imageUrl, {
    timeout: 5000,
    redirect: 'error',
    size: 2097152,  // 2 MB max
  });

  const contentType = response.headers.get('content-type') || '';
  if (!contentType.startsWith('image/')) {
    return res.status(422).json({ error: 'Response is not an image' });
  }

  const buffer = await response.buffer();
  const cacheKey = `img:${Buffer.from(imageUrl).toString('base64')}`;
  await redis.set(cacheKey, buffer, 'EX', 3600);

  res.set('Content-Type', contentType);
  res.send(buffer);
});

SSRF37-003 (High): Changelog sync CNAME redirect chain reaches internal Consul HTTP API

Skill changelogs are often hosted on external services and sync'd via a user-supplied changelogUrl. When the changelog sync fetches this URL with redirect: 'follow' and applies the private IP block only to the initial URL — not to each URL in the redirect chain — an attacker can bypass the check through a CNAME redirect. The attacker registers a domain (e.g., changelog.attacker.com) and creates a CNAME record pointing to consul.internal. The initial DNS resolution of changelog.attacker.com may resolve to a public IP if the CNAME target is not resolvable from the registry's perspective, but a crafted 301 redirect from the attacker's server can redirect to http://consul.internal:8500/v1/kv/?recurse.

Consul's HTTP API returns all key-value pairs in a JSON array when queried with ?recurse. These KV pairs often contain database connection strings, API keys, service mesh tokens, and infrastructure configuration. When stored as "parsed changelog entries" and returned to changelog viewers, this data is exposed to any authenticated registry user. The attack requires only control of a domain and the ability to register a skill — it does not require any existing access to the internal network. CVSS 7.5 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).

// VULNERABLE — changelog sync follows redirects; private IP block on initial URL only
// File: services/changelog-sync.js

const fetch = require('node-fetch');
const { isPrivateIp } = require('./utils/ip-validation');

async function syncChangelog(skillId, changelogUrl) {
  const parsed = new URL(changelogUrl);

  // VULNERABILITY: private IP check on initial URL only — does not check redirect targets
  // Attacker uses public domain with 301 redirect to http://consul.internal:8500/v1/kv/?recurse
  const resolved = await dns.resolve4(parsed.hostname);
  for (const ip of resolved) {
    if (isPrivateIp(ip)) throw new Error('Private IP blocked');
  }

  // redirect: 'follow' follows the 301 to consul.internal without IP re-check
  const response = await fetch(changelogUrl, {
    redirect: 'follow',
    timeout: 10000,
  });

  const content = await response.text();

  // Consul KV JSON array stored as changelog content
  await db.query(
    'UPDATE skills SET changelog = $1, changelog_synced_at = NOW() WHERE id = $2',
    [content, skillId]
  );
}

Fix: Set redirect: 'error' to disable redirect following entirely. Apply the private IP check after each DNS resolution step, not just the initial URL. Use an explicit allowlist of known documentation and changelog CDN hostnames (raw.githubusercontent.com, cdn.jsdelivr.net, unpkg.com). Parse the fetched content as plain CommonMark text — never store raw response body. Apply egress firewall rules at the infrastructure level to block outbound connections to internal service mesh ports (8500, 8501, 8300) as defense-in-depth.

// FIXED — redirect:error; hostname allowlist; CommonMark parse only
// File: services/changelog-sync.js

const fetch = require('node-fetch');
const dns = require('dns').promises;
const { isPrivateIp } = require('./utils/ip-validation');
const { unified } = require('unified');
const remarkParse = require('remark-parse');
const remarkHtml = require('remark-html');

const CHANGELOG_HOSTNAME_ALLOWLIST = new Set([
  'raw.githubusercontent.com',
  'cdn.jsdelivr.net',
  'unpkg.com',
  'github.com',
]);

async function syncChangelog(skillId, changelogUrl) {
  let parsed;
  try { parsed = new URL(changelogUrl); } catch {
    throw new Error('Invalid changelogUrl');
  }

  if (!CHANGELOG_HOSTNAME_ALLOWLIST.has(parsed.hostname)) {
    throw new Error(`Changelog hostname not allowed: ${parsed.hostname}`);
  }

  const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
  for (const ip of addresses) {
    if (isPrivateIp(ip)) throw new Error(`Changelog URL resolves to private IP: ${ip}`);
  }

  const response = await fetch(changelogUrl, {
    redirect: 'error',  // no redirect following — CNAME bypass prevented
    timeout: 10000,
    size: 200000,       // 200 KB max for changelog
  });

  const rawContent = await response.text();

  // Parse as CommonMark only — strips any non-markdown content (JSON, HTML, scripts)
  const htmlContent = await unified()
    .use(remarkParse)
    .use(remarkHtml, { sanitize: true })
    .process(rawContent);

  await db.query(
    'UPDATE skills SET changelog = $1, changelog_synced_at = NOW() WHERE id = $2',
    [String(htmlContent), skillId]
  );
}

SSRF37-004 (High): Version check URL SSRF to etcd KV range stored as skill version metadata

Some MCP skill registries implement a version check feature where the registry server periodically pings a user-supplied updateUrl to determine whether a new version of the skill is available. When this endpoint fetches the URL without restricting the target to known npm or GitHub release API hostnames, an attacker can supply the etcd HTTP client endpoint as the updateUrl. The etcd v3 API's /v3/kv/range endpoint returns all keys and values in a specified range when called with an empty key.

The etcd response — a JSON object containing base64-encoded key-value pairs — is parsed as "version metadata" and stored against the skill record. This data is subsequently returned to any user who queries the skill's version information via the registry API or public skill detail page. etcd stores service discovery configuration, database credentials, TLS certificates, and service mesh tokens for the entire cluster. The attack is particularly insidious because version check pings are typically scheduled background jobs that run periodically for all skills, amplifying the attack surface beyond a single request path. CVSS 7.5 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).

// VULNERABLE — version check URL fetched without hostname restriction
// File: workers/version-check-worker.js

const fetch = require('node-fetch');

async function checkSkillVersion(skillId, updateUrl) {
  // VULNERABILITY: no hostname allowlist; no private IP block
  // Attacker sets updateUrl to http://etcd:2379/v3/kv/range
  // POST body: {} — returns all keys in etcd
  const response = await fetch(updateUrl, {
    method: 'GET',
    timeout: 5000,
  });

  const body = await response.json();

  // etcd /v3/kv/range response stored as version metadata
  // base64-encoded keys/values containing DB credentials, TLS certs, tokens
  await db.query(
    'UPDATE skills SET version_metadata = $1, version_checked_at = NOW() WHERE id = $2',
    [JSON.stringify(body), skillId]
  );
}

Fix: Allowlist the target hostnames to npm registry and GitHub release API endpoints only (registry.npmjs.org, api.github.com). Apply a DNS-based private IP block after resolution. Return only a parsed version string field from the response — never store the raw response body. Use a strict Zod schema that extracts only version (semver string) and publishedAt (ISO 8601 timestamp) from the response; discard everything else. Implement egress firewall rules blocking ports 2379 and 2380 (etcd) as infrastructure-level defense.

// FIXED — hostname allowlist; DNS IP block; version string only extracted
// File: workers/version-check-worker.js

const fetch = require('node-fetch');
const dns = require('dns').promises;
const semver = require('semver');
const { z } = require('zod');
const { isPrivateIp } = require('./utils/ip-validation');

const VERSION_HOSTNAME_ALLOWLIST = new Set([
  'registry.npmjs.org',
  'api.github.com',
]);

const VersionResponseSchema = z.object({
  version: z.string().refine(v => semver.valid(v) !== null, 'Must be valid semver'),
}).passthrough();  // allow extra fields but only extract version

async function checkSkillVersion(skillId, updateUrl) {
  let parsed;
  try { parsed = new URL(updateUrl); } catch {
    throw new Error('Invalid updateUrl');
  }

  if (!VERSION_HOSTNAME_ALLOWLIST.has(parsed.hostname)) {
    throw new Error(`Version check hostname not allowed: ${parsed.hostname}`);
  }

  const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
  for (const ip of addresses) {
    if (isPrivateIp(ip)) throw new Error(`Version check URL resolves to private IP: ${ip}`);
  }

  const response = await fetch(updateUrl, {
    timeout: 5000,
    redirect: 'error',
    size: 65536,  // 64 KB max
  });

  const body = await response.json();
  const result = VersionResponseSchema.safeParse(body);
  if (!result.success) {
    throw new Error('Version check response does not contain valid semver');
  }

  // Store only the version string — never the raw response body
  await db.query(
    'UPDATE skills SET latest_version = $1, version_checked_at = NOW() WHERE id = $2',
    [result.data.version, skillId]
  );
}

Compound attack chain: documentation SSRF to IAM credentials to full registry compromise

The four SSRF37 vulnerabilities represent different fetch surfaces that can be chained through IAM credential escalation.

Phase 1 — IAM credential exfiltration (SSRF37-001). The attacker registers a skill with docsUrl set to the EC2 metadata service. The registry server fetches the endpoint, stores the IAM credentials as documentation, and renders them publicly. The attacker browses the public skill detail page to retrieve the AccessKeyId, SecretAccessKey, and session Token.

Phase 2 — Internal service enumeration (SSRF37-003 / SSRF37-004). With IAM credentials, the attacker can query the registry's cloud environment to discover internal DNS names for Consul and etcd. These are then set as changelogUrl and updateUrl respectively. The registry's background sync workers retrieve and store this data.

Phase 3 — Infrastructure secret harvest (SSRF37-004). The etcd KV range response contains database credentials, service mesh certificates, and other infrastructure secrets. These are returned to any user querying the skill's version metadata endpoint.

Chain severity: This chain progresses from unauthenticated skill registration (open to all users) to full infrastructure secret exfiltration. The IAM credential phase (SSRF37-001) is typically the entry point because EC2 metadata is universally reachable from EC2-hosted services and returns rich credentials in a well-known format. The fix for SSRF37-001 (hostname allowlist + DNS IP block + CommonMark parse only) must be applied before any other SSRF mitigation has value.

Detection with tree-sitter queries

Query 1 — fetch(userUrl) without private IP check in same function. Matches fetch() call expressions inside async functions where the URL argument is not a string literal — suggesting a user-supplied URL — and where the function body does not contain an isPrivateIp or equivalent check.

; tree-sitter query: fetch with non-literal URL missing private IP check (SSRF37 patterns)

(function_declaration
  body: (statement_block
    (expression_statement
      (await_expression
        (call_expression
          function: (identifier) @fn (#eq? @fn "fetch")
          arguments: (arguments
            (identifier) @url-arg  ; variable URL — not a string literal
          )
        )
      )
    )
  )
) @fetch-variable-url

; Review each @fetch-variable-url: does the containing function validate hostname
; against an allowlist AND block private IPs via DNS lookup?
; If not, potential SSRF.

Query 2 — redirect: 'follow' in fetch options. Matches fetch() calls where the options object explicitly sets redirect to 'follow' — the bypass vector for SSRF37-003 CNAME redirect chains.

; tree-sitter query: redirect:'follow' in fetch options (SSRF37-003 pattern)

(call_expression
  function: (identifier) @fn (#eq? @fn "fetch")
  arguments: (arguments
    (_) @url
    (object
      (pair
        key: (property_identifier) @key (#eq? @key "redirect")
        value: (string) @val (#eq? @val "follow")
      )
    )
  )
) @fetch-redirect-follow

; Each @fetch-redirect-follow: potential redirect-chain SSRF bypass.
; Fix: change to redirect:'error' and add redirect target IP re-check logic.

Query 3 — Raw response body stored in DB without content type check. Matches patterns where response.text() or response.json() output is passed directly to a db.query( call without an intermediate content-type check — the storage pattern that makes SSRF findings publicly visible.

; tree-sitter query: response.text()/json() directly into db.query (SSRF storage amplifier)

(variable_declaration
  (variable_declarator
    name: (identifier) @content
    value: (await_expression
      (call_expression
        function: (member_expression
          object: (identifier) @resp
          property: (property_identifier) @method (#match? @method "^(text|json|buffer)$")
        )
      )
    )
  )
)

; Look for subsequent db.query(..., @content, ...) — indicates raw response stored in DB
; without content-type gate or response body parsing.

Summary

ID Severity Surface Root cause Fix
SSRF37-001 Critical Documentation sync (docsUrl) No hostname allowlist or DNS private-IP block; raw response body stored as public skill docs; EC2 IAM credentials exposed Hostname allowlist; DNS IP block; redirect:'error'; parse only CommonMark AST
SSRF37-002 High README image proxy (imageUrl) No hostname allowlist; no Content-Type: image/* check; Prometheus metrics text served as cached image Badge CDN hostname allowlist; DNS IP block; validate Content-Type: image/*; 2 MB limit
SSRF37-003 High Changelog sync (changelogUrl) redirect:'follow' with IP check on initial URL only; CNAME chain bypasses to Consul HTTP API redirect:'error'; hostname allowlist; CommonMark parse only; infra egress rules on port 8500
SSRF37-004 High Version check (updateUrl) No hostname allowlist; etcd /v3/kv/range response stored as skill version metadata and returned to all viewers npm registry + GitHub API hostname allowlist; DNS IP block; extract version string only via Zod

Checklist for MCP skill registry operators: (1) Grep all service and worker files for fetch( and axios.get( — audit every call where the URL is a variable (not a literal) for hostname allowlist and DNS private-IP block. (2) Confirm redirect: 'error' is set on all external fetch calls — never 'follow'. (3) Verify all documentation, changelog, and README sync functions parse fetched content as markdown/text with a sanitizing parser, never storing raw response bodies. (4) Confirm version check endpoints return only a parsed semver string, not raw API response bodies. (5) Audit egress firewall rules — confirm ports 2379 (etcd), 8500 (Consul), and 9090 (Prometheus) are blocked outbound from registry services. See also: SA-SKL-SSRF36 for SSRF in npm registry proxy; SA-SKL-DESER20 — deserialization vulnerabilities reachable if SSRF succeeds against Redis or MongoDB.

Scan your MCP skills for SSRF37 and 2400+ other patterns

SkillAudit continuously audits MCP server and Claude skill codebases for CORS misconfigurations, injection vulnerabilities, deserialization flaws, SSRF, and privilege escalation. Get findings in minutes.

Get started at skillaudit.dev