SA-SKL-SSRF40 — Server-Side Request Forgery

SSRF in MCP Skill Registry Skill Installation and Dependency Download Endpoints

Skill installation and dependency download workflows are inherently fetch-heavy: archives are downloaded, registries are queried for metadata, and provenance attestations are verified against external endpoints. Each user-controlled URL in this pipeline is a potential SSRF vector. SA-SKL-SSRF40 documents four patterns where user-supplied URLs in installation and dependency download endpoints reach internal infrastructure — from EC2 IMDS credential exfiltration through Consul catalog reads, Vault KV secret leakage via redirect chains, and InfluxDB metric exposure via webhook URL validation.

SA-SKL-SSRF40 findings
CRITICALSSRF40-001 — Skill installation endpoint fetches user-supplied downloadUrl — attacker sets to 169.254.169.254; IAM credentials stored as downloaded skill archive and returned to installing user; fix: hostname allowlist (registry.npmjs.org, github.com); DNS private-IP block; return only parsed archive contents
CRITICALSSRF40-002 — Dependency pre-fetch downloads user-supplied registryUrl — attacker sets to internal Consul; /v1/catalog/services JSON stored as dependency metadata; fix: npm registry hostname allowlist; redirect:error; Zod parse name/version fields only
HIGHSSRF40-003 — Install verification fetches user-supplied sigstoreUrl with redirect:follow — attacker controls CNAME to internal Vault; Vault KV response stored as provenance attestation; fix: redirect:error; Sigstore hostname allowlist
HIGHSSRF40-004 — Post-install hook URL validation fetches user-supplied webhookUrl — attacker sets to internal InfluxDB HTTP API; InfluxDB response body stored as hook confirmation and returned to any registry admin; fix: allowlist of known CI/CD webhook hosts; return only HTTP status code

SSRF40-001 — Installation endpoint fetches user-supplied downloadUrl leaking IAM credentials

The skill installation endpoint allows users to provide a custom downloadUrl for skills hosted outside the main npm registry — a feature added for private GitHub releases and enterprise artifact repositories. The endpoint fetches the URL using Node.js fetch() without any hostname validation. When an attacker sets downloadUrl to http://169.254.169.254/latest/meta-data/iam/security-credentials/, the registry server (running on EC2) returns the instance’s IAM role name. A second fetch to the full credentials path returns AccessKeyId, SecretAccessKey, and Token, which are stored as the “downloaded archive” and returned as the installation response.

Vulnerable
// SSRF40-001 — VULNERABLE
// No hostname validation on downloadUrl — IMDS credential exfiltration.

router.post('/install', requireSession, async (req, res) => {
  const { skillId, downloadUrl } = req.body;

  const archiveRes = await fetch(downloadUrl); // VULNERABLE: no hostname check
  const archiveBuf = Buffer.from(await archiveRes.arrayBuffer());
  // IAM credentials stored as archive bytes if downloadUrl = 169.254.169.254

  await installSkill(skillId, archiveBuf, req.session.orgId);
  res.json({ installed: true });
});
Fixed
// SSRF40-001 — FIXED
// 1. Hostname allowlist: only known registry and GitHub release CDN hosts.
// 2. DNS-based private-IP block via dns.lookup before fetch.
// 3. Return only parsed archive metadata, never raw bytes.

const dns = require('dns').promises;
const DOWNLOAD_HOSTS = new Set([
  'registry.npmjs.org', 'github.com', 'objects.githubusercontent.com',
  'npm.pkg.github.com',
]);

async function safeDownload(url) {
  const parsed = new URL(url);
  if (!DOWNLOAD_HOSTS.has(parsed.hostname))
    throw Object.assign(new Error('downloadUrl: hostname not in allowlist'), { status: 400 });

  const { address } = await dns.lookup(parsed.hostname);
  if (/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|127\.|169\.254\.)/.test(address))
    throw Object.assign(new Error('downloadUrl: resolved to private IP'), { status: 400 });

  const res = await fetch(url, { redirect: 'error', signal: AbortSignal.timeout(10000) });
  if (!res.ok) throw new Error(`Download failed: ${res.status}`);
  const buf = Buffer.from(await res.arrayBuffer());
  return extractArchiveMetadata(buf); // parse only — never return raw bytes
}

router.post('/install', requireSession, async (req, res) => {
  const { skillId, downloadUrl } = req.body;
  const meta = await safeDownload(downloadUrl);
  await installSkill(skillId, meta, req.session.orgId);
  res.json({ installed: true });
});

SSRF40-002 — Dependency pre-fetch fetches user-supplied registryUrl returning Consul catalog

When installing a skill, the registry pre-fetches dependency metadata from the npm registry. The endpoint accepts a custom registryUrl parameter for private npm registries. Without a hostname allowlist, an attacker who sets registryUrl to http://consul.internal:8500 receives the full Consul service catalog JSON stored as the skill’s dependency metadata, exposing all internal service addresses and health check endpoints.

Vulnerable
// SSRF40-002 — VULNERABLE
// User-supplied registryUrl fetched without hostname check — Consul catalog read.

router.post('/install/prefetch-deps', requireSession, async (req, res) => {
  const { packageName, version, registryUrl = 'https://registry.npmjs.org' } = req.body;
  const metaUrl = `${registryUrl}/${packageName}/${version}`;
  const meta = await fetch(metaUrl).then(r => r.json()); // VULNERABLE
  res.json({ deps: meta.dependencies });
});
Fixed
// SSRF40-002 — FIXED
// 1. registryUrl must be in npm registry allowlist.
// 2. redirect:error; DNS private-IP block.
// 3. Parse only name/version fields from response via Zod.

const REGISTRY_HOSTS = new Set([
  'registry.npmjs.org', 'npm.pkg.github.com', 'registry.yarnpkg.com',
]);
const DepMetaSchema = z.object({
  name: z.string().max(214),
  version: z.string().max(50),
  dependencies: z.record(z.string().max(50)).optional().default({}),
});

router.post('/install/prefetch-deps', requireSession, async (req, res) => {
  const { packageName, version, registryUrl = 'https://registry.npmjs.org' } = req.body;
  const parsed = new URL(registryUrl);
  if (!REGISTRY_HOSTS.has(parsed.hostname))
    return res.status(400).json({ error: 'registryUrl: not in allowlist' });

  const meta = await fetch(`${registryUrl}/${encodeURIComponent(packageName)}/${version}`, {
    redirect: 'error', signal: AbortSignal.timeout(8000),
  }).then(r => r.json());

  const safe = DepMetaSchema.parse(meta); // strips all fields except name/version/dependencies
  res.json({ deps: safe.dependencies });
});

SSRF40-003 — Install verification follows redirects to Vault via CNAME chain

The installation verification step pings a Sigstore endpoint to validate the skill’s provenance attestation. The sigstoreUrl is accepted from the skill manifest and fetched with redirect:follow (the fetch default). An attacker registers a public domain and sets its CNAME to vault.internal. The redirect chain resolves to Vault’s HTTP API, and the KV secret response is stored as the provenance attestation, potentially exposing database credentials or API tokens to the installing user.

Vulnerable
// SSRF40-003 — VULNERABLE
// redirect:follow allows CNAME chain to reach Vault — KV secrets returned as attestation.

async function verifyInstallAttestation(sigstoreUrl) {
  const res = await fetch(sigstoreUrl); // VULNERABLE: redirect:follow by default
  return res.json(); // Vault KV response stored as attestation
}
Fixed
// SSRF40-003 — FIXED
// 1. redirect:error — no redirect chains.
// 2. Sigstore hostname allowlist.
// 3. Parse only DSSE envelope fields via Zod.

const SIGSTORE_HOSTS = new Set([
  'rekor.sigstore.dev', 'fulcio.sigstore.dev', 'tsa.sigstore.dev',
]);
const DSSESchema = z.object({
  payloadType: z.string().max(100),
  payload: z.string().max(50000),
  signatures: z.array(z.object({ sig: z.string(), keyid: z.string().optional() })),
});

async function verifyInstallAttestation(sigstoreUrl) {
  const parsed = new URL(sigstoreUrl);
  if (!SIGSTORE_HOSTS.has(parsed.hostname))
    throw new Error('sigstoreUrl: hostname not in Sigstore allowlist');

  const res = await fetch(sigstoreUrl, {
    redirect: 'error',  // no redirects
    signal: AbortSignal.timeout(8000),
  });
  return DSSESchema.parse(await res.json()); // only DSSE envelope fields
}

SSRF40-004 — Post-install webhook URL validation fetches user-supplied webhookUrl returning InfluxDB responses

After skill installation, the registry validates the post-install webhook URL by sending a test request to confirm it responds. The URL is taken directly from the skill manifest without hostname validation. An attacker who sets webhookUrl to http://influxdb.internal:8086/query?db=metrics&q=SHOW+MEASUREMENTS receives the InfluxDB query response stored as the “hook confirmation” and surfaced to any admin who views installation logs.

Vulnerable
// SSRF40-004 — VULNERABLE
// webhookUrl fetched without hostname check — InfluxDB metrics response returned to admin.

router.post('/install/validate-webhook', requireSession, requireRole('admin'), async (req, res) => {
  const { webhookUrl } = req.body;
  const hookRes = await fetch(webhookUrl, { method: 'POST', body: JSON.stringify({ test: true }) });
  const confirmation = await hookRes.json();
  res.json({ valid: hookRes.ok, confirmation }); // InfluxDB JSON returned to admin
});
Fixed
// SSRF40-004 — FIXED
// 1. webhookUrl must match CI/CD webhook allowlist pattern.
// 2. Only return HTTP status code — never return response body.
// 3. DNS private-IP block.

const WEBHOOK_PATTERN = /^https:\/\/(hooks\.slack\.com|api\.github\.com|hooks\.zapier\.com)\//;

router.post('/install/validate-webhook', requireSession, requireRole('admin'), async (req, res) => {
  const { webhookUrl } = req.body;
  if (!WEBHOOK_PATTERN.test(webhookUrl))
    return res.status(400).json({ error: 'webhookUrl: not in webhook host allowlist' });

  const { address } = await dns.lookup(new URL(webhookUrl).hostname);
  if (/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|127\.|169\.254\.)/.test(address))
    return res.status(400).json({ error: 'webhookUrl: resolved to private IP' });

  const hookRes = await fetch(webhookUrl, {
    method: 'POST',
    body: JSON.stringify({ type: 'skillaudit.install.test' }),
    headers: { 'Content-Type': 'application/json' },
    redirect: 'error',
    signal: AbortSignal.timeout(5000),
  });
  // Return only the HTTP status code — never the response body
  res.json({ valid: hookRes.ok, status: hookRes.status });
});

Related findings