SA-SKL-SSRF32 — Server-Side Request Forgery

SSRF in MCP Skill Registry Skill Installation and Dependency Download Pipeline

The skill installation pipeline processes multiple user-supplied URLs: the tarball download location, the SRI integrity hash file location, the update check endpoint, and the post-install callback. SA-SKL-SSRF32 covers four SSRF vulnerabilities across these URL input points that allow an attacker to probe and exfiltrate data from internal infrastructure during routine skill installation operations.

SA-SKL-SSRF32 findings at a glance
CRITICALSSRF32-001 — Skill install endpoint fetches user-supplied tarballUrl for direct install; attacker sets to 169.254.169.254/latest/meta-data/iam/; IAM credentials logged in install error log and surfaced in audit report
HIGHSSRF32-002 — Dependency integrity check fetches user-supplied integrityUrl for SRI hash file; attacker sets to internal Vault PKI endpoint; certificate chain JSON stored as integrity file content in the registry database
HIGHSSRF32-003 — Skill update check fetches user-supplied updateCheckUrl polling for new versions; attacker sets to internal Redis cluster; INFO command output parsed as version JSON, exposing Redis configuration and keyspace statistics
HIGHSSRF32-004 — Installation webhook callback fetches user-supplied callbackUrl on install completion; attacker sets to 10.0.0.1 internal service; signed install payload with skill metadata delivered to internal endpoint

SSRF32-001 — tarballUrl SSRF leaks IAM credentials

The skill install endpoint accepts a tarballUrl parameter for direct installation from an arbitrary URL, allowing developers to install skills from private build artifacts or pre-release tarballs. The endpoint fetches the tarball using the server-side HTTP client with no hostname validation, making it a full SSRF vector against the cloud metadata service.

Vulnerable
// SSRF32-001 — VULNERABLE
// Fetches tarballUrl with no hostname validation — attacker targets 169.254.169.254.

async function installSkillFromUrl(tarballUrl, skillId) {
  const response = await fetch(tarballUrl); // VULNERABLE: no SSRF guard
  if (!response.ok) {
    logger.error('tarball fetch failed', { tarballUrl, status: response.status,
      body: await response.text() }); // IAM creds in error body logged to audit trail
  }
  const buffer = await response.arrayBuffer();
  await extractAndInstall(buffer, skillId);
}

Fix: Allowlist HTTPS-only npm registry CDN hostnames (registry.npmjs.org, cdn.jsdelivr.net). Block all private IP ranges using a DNS resolution pre-check before the fetch (dns.lookup() → check against RFC 1918 / link-local ranges). Enforce a 50 MB size limit. Never log response bodies for failed fetches — log only HTTP status and URL.

// SSRF32-001 — FIXED
const { isPrivateIP } = require('../utils/ssrf-guard');
const dns = require('dns').promises;

const TARBALL_HOSTNAME_ALLOWLIST = new Set([
  'registry.npmjs.org', 'cdn.jsdelivr.net', 'github.com', 'gitlab.com'
]);

async function installSkillFromUrl(tarballUrl, skillId) {
  const url = new URL(tarballUrl);
  if (url.protocol !== 'https:') throw new Error('Only HTTPS tarball URLs are allowed');
  if (!TARBALL_HOSTNAME_ALLOWLIST.has(url.hostname)) throw new Error(`Hostname not in allowlist: ${url.hostname}`);

  const { address } = await dns.lookup(url.hostname);
  if (isPrivateIP(address)) throw new Error('Resolved to private IP — SSRF blocked');

  const response = await fetch(tarballUrl, { signal: AbortSignal.timeout(30000) });
  if (!response.ok) {
    logger.error('tarball fetch failed', { tarballUrl: url.hostname + url.pathname, httpStatus: response.status });
    throw new Error(`Tarball fetch failed: ${response.status}`);
  }
  const buffer = await response.arrayBuffer();
  if (buffer.byteLength > 50 * 1024 * 1024) throw new Error('Tarball exceeds 50 MB limit');
  await extractAndInstall(buffer, skillId);
}

SSRF32-002 — integrityUrl fetches internal Vault PKI

The dependency integrity check fetches a user-supplied integrityUrl to retrieve the expected SRI hash for the dependency tarball. An attacker who sets this URL to an internal Vault PKI endpoint receives the PKI certificate chain JSON as the "integrity file" content, which is then stored in the registry database as a base64 string and surfaced in the dependency audit report.

Vulnerable
// SSRF32-002 — VULNERABLE
// integrityUrl fetched with no validation — attacker targets internal Vault PKI.

async function fetchIntegrity(integrityUrl) {
  const response = await fetch(integrityUrl); // VULNERABLE: no SSRF guard
  return response.text(); // stores Vault PKI JSON as "integrity hash" in DB
}

Fix: Allowlist only raw file hosting URLs matching raw.githubusercontent.com and gitlab.com/*/raw/* patterns. Enforce Content-Type: text/plain on the response — reject anything else. Validate the returned content matches a base64-sha512 SRI hash format before storing. Apply DNS private-IP blocking.

// SSRF32-002 — FIXED
const SRI_HASH_RE = /^sha512-[A-Za-z0-9+/]+=*$/;
const RAW_URL_RE = /^https:\/\/(raw\.githubusercontent\.com|gitlab\.com\/[^/]+\/[^/]+\/-\/raw\/)/;

async function fetchIntegrity(integrityUrl) {
  if (!RAW_URL_RE.test(integrityUrl)) throw new Error('integrityUrl must be a raw GitHub/GitLab file URL');
  const { address } = await dns.lookup(new URL(integrityUrl).hostname);
  if (isPrivateIP(address)) throw new Error('SSRF blocked');
  const response = await fetch(integrityUrl, { signal: AbortSignal.timeout(10000) });
  const contentType = response.headers.get('content-type') || '';
  if (!contentType.startsWith('text/plain')) throw new Error('integrity file must be text/plain');
  const text = (await response.text()).trim();
  if (!SRI_HASH_RE.test(text)) throw new Error('Invalid SRI hash format');
  return text;
}

SSRF32-003 — updateCheckUrl probes internal Redis as version endpoint

The update check worker polls a skill's configured updateCheckUrl to detect new versions. An attacker who sets this URL to http://redis:6379/INFO receives Redis's INFO command output (via HTTP/1.0 protocol confusion against the Redis TCP port), which is then parsed as the version JSON response and stored as "latest version" metadata in the registry.

Vulnerable
// SSRF32-003 — VULNERABLE
// updateCheckUrl fetched with no validation — protocol confusion against Redis.

async function checkForUpdate(updateCheckUrl, currentVersion) {
  const response = await fetch(updateCheckUrl); // VULNERABLE: http:// allowed, redis port reachable
  const data = await response.json(); // Redis INFO text parsed as JSON — parse error stored as "version"
  return semver.gt(data.version, currentVersion);
}

Fix: Allowlist only the npm registry API hostname for version checks (registry.npmjs.org/packagename). Block HTTP (require HTTPS). Apply DNS private-IP blocking. Enforce a JSON response content-type. Reject responses larger than 64 KB.

// SSRF32-003 — FIXED
async function checkForUpdate(packageName, currentVersion) {
  // updateCheckUrl is NOT user-supplied — constructed server-side from package name
  const url = `https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`;
  const response = await fetch(url, { signal: AbortSignal.timeout(10000) });
  if (!response.headers.get('content-type')?.includes('application/json')) {
    throw new Error('Unexpected content-type from npm registry');
  }
  const data = await response.json();
  return { hasUpdate: semver.gt(data.version, currentVersion), latest: data.version };
}

SSRF32-004 — callbackUrl probes internal service on install completion

The installation pipeline fires a webhook callback to a user-supplied callbackUrl on successful install completion. The callback body includes a signed payload containing the skill ID, install timestamp, registry host, and a summary of resolved dependency versions. An attacker who sets callbackUrl to an internal service receives this signed payload as an HTTP POST body, which may reveal internal service endpoints and dependency metadata.

Vulnerable
// SSRF32-004 — VULNERABLE
// callbackUrl fetched with no validation — attacker probes 10.0.0.1 internal service.

async function fireInstallCallback(callbackUrl, installResult) {
  await fetch(callbackUrl, { // VULNERABLE: no SSRF guard, follows redirects
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(installResult), // includes signed skill metadata
  });
}

Fix: Apply DNS private-IP blocking before the callback fetch. Set redirect: 'error' to prevent redirect-based bypass. The callback response body should be discarded (success is defined by HTTP 2xx status alone). Return only a boolean success indicator to the callback, never the full install result object.

// SSRF32-004 — FIXED
async function fireInstallCallback(callbackUrl, skillId) {
  const url = new URL(callbackUrl);
  if (url.protocol !== 'https:') throw new Error('callbackUrl must be HTTPS');
  const { address } = await dns.lookup(url.hostname);
  if (isPrivateIP(address)) throw new Error('SSRF blocked: private IP');

  const response = await fetch(callbackUrl, {
    method: 'POST',
    redirect: 'error',  // no redirect following
    signal: AbortSignal.timeout(15000),
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ success: true, skillId }), // only boolean + public skillId
  });

  // Discard response body entirely
  await response.body?.cancel();
  return response.ok;
}

Summary

FindingInputInternal TargetFix
SSRF32-001tarballUrl169.254.169.254 IAM metadataHTTPS + CDN hostname allowlist + DNS private-IP block + no response body logging
SSRF32-002integrityUrlInternal Vault PKIRaw GitHub/GitLab URL regex + text/plain content-type + SRI hash format validation
SSRF32-003updateCheckUrlInternal Redis INFOServer-side npm registry URL construction; remove user-supplied URL input
SSRF32-004callbackUrl10.0.0.1 internal serviceDNS private-IP block + redirect:error + return only boolean to callback

Related: SA-SKL-SSRF31 (skill preview and documentation rendering SSRF), SA-SKL-SSRF30 (external integration and third-party service SSRF). Run SkillAudit to detect all SSRF32 patterns in your MCP skill registry.