Claude MCP skill SSRF — npm registry proxy and package metadata fetch endpoints
SA-SKL-SSRF36 documents four SSRF vulnerabilities in MCP skill registry npm registry proxy and package metadata fetch endpoints. User-supplied registry URLs are fetched server-side without host validation, enabling cloud IAM credential theft via the metadata endpoint; readme and changelog URL parameters fetch from internal Vault and Kubernetes API services and return their responses in rendered output; and an open redirect via homepage URL traversal reaches internal services by following attacker-controlled Location headers.
registryUrl server-side; attacker sets to 169.254.169.254; cloud IAM credentials returned directly in proxy response body
readmeUrl; attacker sets to internal Vault (http://vault.internal:8200/v1/secret/data/db-creds); Vault secret JSON rendered as README markdown and served publicly in UI
changelogUrl; attacker sets to Kubernetes API server (https://kubernetes.default:443/api/v1/namespaces); K8s pod list JSON returned as changelog content
homepageUrl server-side with no SSRF guard; open redirect to internal services via Location: http://internal-service response from attacker-controlled homepage
SSRF36-001 (Critical): User-supplied registryUrl fetched server-side returns cloud IAM credentials
MCP skill registries that support custom package registry sources allow users to supply a registryUrl parameter pointing to private npm registries (GitHub Packages, Verdaccio, Artifactory). The package metadata fetch endpoint uses this URL as the base for server-side HTTP requests to retrieve package name, version, and description. When no host allowlist or DNS-based private IP block is applied, an attacker sets registryUrl to the AWS IMDSv1 endpoint http://169.254.169.254/latest/meta-data/iam/security-credentials/. The server-side fetch retrieves the IAM role name, then follows up with a second fetch to that role's credential endpoint. The full response body — containing AccessKeyId, SecretAccessKey, and Token — is returned to the attacker in the proxy response body unchanged.
These credentials are valid for the duration of the IAM role's session (typically 1–12 hours) and provide the same level of AWS access as the application's IAM role — which typically includes S3 bucket access, DynamoDB read/write, and in some configurations ECR push/pull access. CVSS 9.8 (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N).
// VULNERABLE — SSRF36-001: user-supplied registryUrl fetched without host validation
// File: routes/registry-proxy.js
const fetch = require('node-fetch');
router.get('/packages/:name', authenticate, async (req, res) => {
const { registryUrl } = req.query;
const { name } = req.params;
// VULNERABILITY: registryUrl is fully attacker-controlled
// fetch() will follow redirects by default; no DNS-based private IP block
// Attacker sets registryUrl=http://169.254.169.254/latest/meta-data/iam/security-credentials/
const url = `${registryUrl}/${encodeURIComponent(name)}`;
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.NPM_TOKEN}` }
});
// Raw response body returned to attacker — includes IAM credential JSON on metadata endpoint
const data = await response.json();
res.json(data);
});
Fix: Validate registryUrl against an explicit allowlist of known npm registry hostnames before making any server-side request. Perform DNS resolution of the target hostname and block requests where any resolved IP falls within RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), link-local (169.254.0.0/16), loopback (127.0.0.0/8), or IPv6 ULA ranges. Set redirect: 'error' to prevent redirect-based bypass. Parse only the specific fields needed from the registry response (name, version, description) and return a shaped response — never return the raw response body.
// FIXED — SSRF36-001: allowlist + DNS-based private IP block; shaped response only
// File: routes/registry-proxy.js
const fetch = require('node-fetch');
const dns = require('dns').promises;
const ipRangeCheck = require('ip-range-check');
const REGISTRY_ALLOWLIST = new Set([
'registry.npmjs.org',
'npm.pkg.github.com',
'registry.yarnpkg.com',
// Add enterprise Verdaccio/Artifactory hostnames after CI validation
]);
const PRIVATE_RANGES = [
'10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16',
'127.0.0.0/8', '169.254.0.0/16', '::1/128', 'fc00::/7',
];
async function validateRegistryUrl(rawUrl) {
const u = new URL(rawUrl);
if (!REGISTRY_ALLOWLIST.has(u.hostname)) {
throw new Error(`Registry host not in allowlist: ${u.hostname}`);
}
const { address } = await dns.lookup(u.hostname);
if (ipRangeCheck(address, PRIVATE_RANGES)) {
throw new Error('Registry host resolves to private IP range');
}
return u;
}
router.get('/packages/:name', authenticate, async (req, res) => {
const { registryUrl } = req.query;
const { name } = req.params;
const validatedBase = await validateRegistryUrl(registryUrl);
const url = `${validatedBase.origin}/${encodeURIComponent(name)}`;
const response = await fetch(url, {
redirect: 'error', // no redirect following — prevents redirect-based bypass
headers: { Authorization: `Bearer ${process.env.NPM_TOKEN}` },
});
const raw = await response.json();
// Return only the fields we need — never the raw response body
res.json({
name: raw.name,
version: raw['dist-tags']?.latest,
description: raw.description,
});
});
SSRF36-002 (High): User-supplied readmeUrl fetched server-side exposes internal Vault secrets
Package registry entries include a readmeUrl field pointing to the package's README document, displayed in the skill registry UI as rendered markdown. When users can supply a custom readmeUrl and the registry server fetches this URL server-side before rendering it as markdown, the fetch occurs within the registry's internal network context — where services like HashiCorp Vault are accessible by hostname without authentication (when using Vault's AppRole or Token auth tied to the server's network identity).
An attacker sets readmeUrl to http://vault.internal:8200/v1/secret/data/db-creds. The server fetches the Vault API endpoint, which returns a JSON blob containing plaintext database credentials. The registry markdown renderer converts this JSON to a code block and serves it as the package README to any user who views the package listing — publicly, in the UI, with no authentication required. CVSS 8.6 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).
// VULNERABLE — SSRF36-002: user-supplied readmeUrl fetched without host validation
// File: routes/packages.js
router.get('/packages/:name/readme', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
// VULNERABILITY: pkg.readmeUrl is user-supplied and not validated
// Fetches from internal Vault, metadata endpoints, Kubernetes API if attacker-controlled
const readmeResponse = await fetch(pkg.readmeUrl);
const rawContent = await readmeResponse.text();
// Raw response (Vault secret JSON, K8s pod list, etc.) rendered as markdown
const html = markdownRenderer.render(rawContent);
res.send(html);
});
Fix: Derive readmeUrl from the package's registry metadata entry rather than from user-supplied input. If the URL must be user-supplied, validate that the scheme is https and the hostname is in an explicit allowlist (e.g., raw.githubusercontent.com, cdn.jsdelivr.net). Apply the same DNS-based private IP block as SSRF36-001. Never render raw fetch response content — parse the response as CommonMark-only markdown with a strict allowlist of permitted HTML elements, and strip all code blocks whose language identifier is json and whose content matches credential field patterns.
// FIXED — SSRF36-002: allowlist-validated readmeUrl; DNS block; CommonMark-only render
// File: routes/packages.js
const README_HOST_ALLOWLIST = new Set([
'raw.githubusercontent.com',
'cdn.jsdelivr.net',
'unpkg.com',
'gitlab.com',
]);
router.get('/packages/:name/readme', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
const readmeUrl = pkg.readmeUrl; // from registry metadata, not user query param
if (!readmeUrl) return res.json({ html: '' });
const u = new URL(readmeUrl);
if (u.protocol !== 'https:' || !README_HOST_ALLOWLIST.has(u.hostname)) {
return res.status(400).json({ error: 'README URL host not permitted' });
}
// DNS block: prevent DNS rebinding to internal hosts
const { address } = await dns.lookup(u.hostname);
if (ipRangeCheck(address, PRIVATE_RANGES)) {
return res.status(400).json({ error: 'README URL resolves to private IP' });
}
const readmeResponse = await fetch(readmeUrl, { redirect: 'error' });
const raw = await readmeResponse.text();
// Parse as CommonMark only — no raw HTML passthrough; sanitize output
const html = sanitizeHtml(markdownRenderer.render(raw), {
allowedTags: ['p','h1','h2','h3','ul','ol','li','code','pre','a','strong','em'],
allowedAttributes: { 'a': ['href'] },
});
res.json({ html });
});
SSRF36-003 (High): User-supplied changelogUrl fetched server-side returns Kubernetes pod list
Package changelog display follows a similar server-side fetch pattern to README rendering. When changelogUrl is user-supplied and fetched without host validation, an attacker sets it to the Kubernetes API server URL https://kubernetes.default:443/api/v1/namespaces. Within a Kubernetes cluster, the default service account token mounted at /var/run/secrets/kubernetes.io/serviceaccount/token is automatically included in requests made from the pod if the HTTP client uses it — but even without credentials, the Kubernetes API may be accessible from within the cluster network. The JSON response (pod list, namespace list, service list) is returned as the changelog body, exposing the cluster's internal topology to the requesting user.
Even if the Kubernetes API requires authentication, the server-side fetch probes internal DNS names, confirming their existence and the structure of the internal network via different response patterns (connection refused vs authenticated 401 vs unauthenticated 403). This provides valuable reconnaissance for follow-on attacks. CVSS 7.7 (AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).
// VULNERABLE — SSRF36-003: user-supplied changelogUrl fetched without validation
// File: routes/packages.js
router.get('/packages/:name/changelog', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
// VULNERABILITY: no host validation on changelog URL
// Attacker sets changelogUrl to https://kubernetes.default:443/api/v1/namespaces
const response = await fetch(pkg.changelogUrl);
const content = await response.text();
res.json({ changelog: content }); // K8s pod list JSON returned as changelog
});
Fix: Apply the same allowlist and DNS-based block as SSRF36-001 and SSRF36-002. For changelog content specifically, the allowlist should cover only known source-of-truth hostnames: raw.githubusercontent.com, cdn.jsdelivr.net, and similar CDN or VCS raw content endpoints. Set redirect: 'error' to prevent redirect chains that bypass DNS validation by resolving to a public host first then redirecting to an internal one. Never return the raw response body — parse changelog content as plain text or CommonMark and limit the response to a reasonable size (e.g., 50 KB) to prevent exfiltration of large internal responses.
// FIXED — SSRF36-003: CDN-only allowlist; DNS block; redirect:error; size cap
// File: routes/packages.js
const CHANGELOG_HOST_ALLOWLIST = new Set([
'raw.githubusercontent.com',
'cdn.jsdelivr.net',
'gitlab.com',
]);
const MAX_CHANGELOG_BYTES = 50 * 1024;
router.get('/packages/:name/changelog', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
if (!pkg.changelogUrl) return res.json({ changelog: '' });
const u = new URL(pkg.changelogUrl);
if (u.protocol !== 'https:' || !CHANGELOG_HOST_ALLOWLIST.has(u.hostname)) {
return res.status(400).json({ error: 'Changelog URL host not permitted' });
}
const { address } = await dns.lookup(u.hostname);
if (ipRangeCheck(address, PRIVATE_RANGES)) {
return res.status(400).json({ error: 'Changelog URL resolves to private IP' });
}
const response = await fetch(pkg.changelogUrl, {
redirect: 'error',
size: MAX_CHANGELOG_BYTES, // node-fetch size cap: abort if response exceeds limit
});
const content = await response.text();
// Return as parsed CommonMark, not raw response — strips JSON structure if URL was wrong
res.json({ changelog: markdownRenderer.render(content.slice(0, MAX_CHANGELOG_BYTES)) });
});
SSRF36-004 (Medium): homepageUrl open redirect via server-side redirect following reaches internal services
The package homepage endpoint follows user-supplied homepageUrl values server-side to validate that the homepage is reachable or to fetch an Open Graph preview. When the fetch client follows redirects by default and no SSRF guard validates the intermediate and final redirect targets, an attacker registers a package with a homepage URL pointing to an attacker-controlled domain that responds with a Location: http://10.0.0.1/admin redirect. The registry server follows the redirect to the internal service and returns the response — bypassing the initial hostname check that only validated the first URL.
This redirect-chain bypass is particularly dangerous because many implementations validate only the user-supplied URL, not the URLs encountered during redirect following. Cloud metadata endpoints, internal admin panels, and database management UIs at RFC 1918 addresses are reachable via a single redirect hop from a public attacker-controlled domain. CVSS 6.5 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
// VULNERABLE — SSRF36-004: homepage URL followed server-side; redirect not blocked
// File: routes/packages.js
router.get('/packages/:name/homepage-preview', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
// VULNERABILITY: fetch follows redirects by default
// attacker homepage at attacker.com responds with Location: http://10.0.0.1/admin
// Server follows redirect to internal service and returns its response
const response = await fetch(pkg.homepageUrl); // redirect:follow is default
const html = await response.text();
res.json({ preview: html.slice(0, 1000) });
});
Fix: Never follow server-side redirects for user-supplied URLs. Set redirect: 'error' in all fetch calls involving user-controlled URLs. Validate the initial URL scheme (https only) and hostname against the same DNS-based private IP block used in SSRF36-001 through SSRF36-003. For homepage display, return the user-supplied URL as a client-side link in the UI rather than proxying it server-side — the browser will handle navigation to it, and the same-origin policy constrains what the browser can send. If a preview is genuinely required, use a sandboxed external preview service (e.g., a dedicated headless browser container with egress limited to public internet) rather than making requests from within the registry's internal network.
// FIXED — SSRF36-004: redirect:error; DNS block; return as client-side link instead
// File: routes/packages.js
router.get('/packages/:name/homepage-preview', async (req, res) => {
const pkg = await db.getPackage(req.params.name);
if (!pkg.homepageUrl) return res.json({ homepageUrl: null });
const u = new URL(pkg.homepageUrl);
if (!['http:', 'https:'].includes(u.protocol)) {
return res.status(400).json({ error: 'Homepage URL must use http or https' });
}
// DNS-based private IP block on the initial URL
const { address } = await dns.lookup(u.hostname);
if (ipRangeCheck(address, PRIVATE_RANGES)) {
return res.status(400).json({ error: 'Homepage URL resolves to private IP' });
}
// Return as a validated client-side link — browser handles navigation
// No server-side fetch: no SSRF via redirect chain
res.json({ homepageUrl: pkg.homepageUrl, openInBrowser: true });
});
Detection with tree-sitter queries
The highest-value patterns in this advisory are unconstrained fetch(userSuppliedUrl) calls (SSRF36-001 through SSRF36-003), and fetch(url) calls that do not set redirect: 'error' (SSRF36-004). The following tree-sitter queries identify these patterns in Node.js codebases.
Query 1 — fetch() called with a variable derived from request query params or body. Matches fetch() call expressions where the first argument is a string concatenation or template literal that includes a variable derived from req.query, req.body, or req.params — the SSRF36-001 structural signature.
; tree-sitter query: fetch() called with user-supplied URL (SSRF36-001/002/003)
; Matches: fetch(`${req.query.registryUrl}/...`) and similar template literal patterns
(call_expression
function: (identifier) @fn (#eq? @fn "fetch")
arguments: (arguments
(template_string
(template_substitution
(member_expression
object: (member_expression
object: (identifier) @req (#eq? @req "req")
property: (property_identifier) @source
(#match? @source "^(query|body|params)$")
)
)
)
) @url-arg
)
) @ssrf-fetch
; Each @ssrf-fetch: fetch() called with a URL containing user-supplied request data.
; Confirm: is there a hostname allowlist check before this call?
; Fix: validate hostname against allowlist + DNS-based private IP block before fetching.
Query 2 — fetch() called with a variable assigned from a database document field. Matches fetch() where the argument is a property access on a variable assigned from a database query result — the SSRF36-002/003 pattern where user-supplied URLs are stored in the database and fetched on retrieval.
; tree-sitter query: fetch() called with database-retrieved URL field (SSRF36-002/003)
; Matches: fetch(pkg.readmeUrl) / fetch(doc.changelogUrl) where pkg/doc comes from db
(variable_declarator
name: (identifier) @db-var
value: (await_expression
(call_expression
function: (member_expression
property: (property_identifier) @db-method
(#match? @db-method "^(findOne|find|get|query|first)$")
)
)
)
) @db-read
(call_expression
function: (identifier) @fn (#eq? @fn "fetch")
arguments: (arguments
(member_expression
object: (identifier) @obj (#eq? @obj @db-var)
property: (property_identifier) @url-field
(#match? @url-field "Url$|URL$|url$|href$|endpoint$")
) @url-arg
)
) @ssrf-db-url
; Each @ssrf-db-url: fetch() called with a URL field from a database record.
; Database URL fields are user-supplied — treat as untrusted; apply allowlist + DNS block.
Query 3 — fetch() without redirect: 'error' option. Matches fetch() call expressions that either pass no options object or pass an options object that does not include redirect: 'error' — identifying redirect-following SSRF vectors (SSRF36-004).
; tree-sitter query: fetch() without redirect:'error' (SSRF36-004)
; Matches: fetch(url) with no options, or fetch(url, {}) missing redirect:'error'
(call_expression
function: (identifier) @fn (#eq? @fn "fetch")
arguments: (arguments
(_) @url
(object
!( (pair
key: (property_identifier) @redirect-key (#eq? @redirect-key "redirect")
value: (string) @redirect-val (#eq? @redirect-val "error")
) )
) @opts
)
) @missing-redirect-error
; Each @missing-redirect-error: fetch() does not block redirects.
; Fix: add redirect:'error' to all fetch() calls involving potentially user-supplied URLs.
Summary
| ID | Severity | Vector | Root cause | Fix |
|---|---|---|---|---|
| SSRF36-001 | Critical | registryUrl — cloud IAM theft | fetch(registryUrl + name) with no host validation; metadata endpoint returns IAM credentials in raw response |
Explicit hostname allowlist; DNS-based private IP block; return only parsed fields (name/version/description) |
| SSRF36-002 | High | readmeUrl — Vault secret exfil | fetch(pkg.readmeUrl) without host validation; Vault API JSON rendered as README markdown in public UI |
allowlist (raw.githubusercontent.com, cdn.jsdelivr.net); DNS block; CommonMark-only sanitized render |
| SSRF36-003 | High | changelogUrl — K8s API exposure | fetch(pkg.changelogUrl) without host validation; K8s namespace/pod list JSON returned as changelog |
CDN-only allowlist; DNS block; redirect:'error'; 50 KB size cap; CommonMark render |
| SSRF36-004 | Medium | homepageUrl — open redirect to internal | fetch() follows redirects by default; attacker homepage responds with Location: http://internal/ |
redirect:'error'; DNS block on initial URL; return as client-side link, not server-side proxy |
SSRF prevention checklist for MCP skill registry npm proxy operators: (1) Grep all route and worker files for fetch(, axios.get(, got(, request( — flag every call where any part of the URL derives from request params, body, query, or database fields. (2) Confirm every server-side fetch against a user-supplied URL applies a hostname allowlist before making the request. (3) Confirm every server-side fetch applies a DNS-based private IP block after allowlist validation to prevent DNS rebinding. (4) Confirm all fetch calls set redirect: 'error' — redirect following is a common allowlist bypass. (5) Confirm registry proxy endpoints return only specific parsed fields from the registry response, never the raw response body. (6) Confirm README and changelog endpoints apply content-type validation and CommonMark-only rendering — never return raw response content. (7) Confirm homepage display returns URLs as client-side links rather than server-side proxied content. (8) Run the three tree-sitter queries above in CI to catch new user-URL-to-fetch patterns before they reach production. See also: SA-SKL-DESER19 for SSRF via CSS @import in report generation.
Scan your MCP skills for SSRF36 and 2400+ other patterns
SkillAudit continuously audits MCP server and Claude skill codebases for SSRF vulnerabilities, injection flaws, CORS misconfigurations, deserialization issues, and privilege escalation. Get findings in minutes.
Get started at skillaudit.dev