← Blog

Claude skill SSRF URL parsing security — SA-SKL-SSRF3

MCP skills that make outbound HTTP requests (webhook delivery, URL preview, proxy fetch) are prime SSRF targets. The standard defense — parse the URL, check the hostname against an allowlist or blocklist of internal ranges, then fetch — fails when the parser used for validation and the HTTP client used for fetching resolve URLs differently. SA-SKL-SSRF3-001 through SSRF3-004 document four URL parsing inconsistency patterns that allow attackers to bypass hostname validation and reach internal services.

By SkillAudit  |  6 Nov 2026

Why URL parsing inconsistency enables SSRF bypasses in MCP skills

The validate-then-fetch pattern looks straightforward: extract the hostname from the user-supplied URL, verify it is not an internal address, then pass the URL to the HTTP client. The flaw is that URL parsing is not a solved problem — different parsers disagree on how to handle userinfo @ characters in the authority component, alternate IP notations (IPv6, octal, decimal, hex), HTTP redirects, and DNS TTL races. Each disagreement is an opportunity for an attacker to construct a URL that the validator considers safe but the HTTP client resolves to an internal address. The four SA-SKL-SSRF3 patterns cover the most common gaps found in community MCP skill audits.

SA-SKL-SSRF3 in scope: SSRF3-001 (validator vs fetch authority inconsistency via userinfo @), SSRF3-002 (IPv6-encoded and alternate-notation loopback bypass), SSRF3-003 (HTTP redirect chain to internal target), SSRF3-004 (DNS rebinding via TTL 0). All four are detected by SkillAudit's SSRF static analysis and runtime probe suite.

SSRF3-001 — Validator vs fetch authority inconsistency

A common SSRF mitigation pattern splits the user-supplied URL on @ and checks whether the substring before @ matches a trusted hostname, or simply checks whether a trusted hostname appears anywhere in the URL string. An attacker supplies http://trusted.com@attacker.com/ssrf: the naive string check finds trusted.com and passes validation, but new URL(input).hostname correctly returns attacker.com (the userinfo component before @ is a username, not the host). The fix is to always use the URL API for both parsing and hostname extraction — never perform string operations on a URL to find the hostname.

// VULNERABLE: naive string check is fooled by userinfo @ in URL
async function proxyFetch(inputUrl) {
  // Attacker input: "http://trusted.com@attacker.com/ssrf"
  // indexOf / includes check finds "trusted.com" — passes validation
  if (!inputUrl.includes('trusted.com')) {
    throw new Error('URL must reference trusted.com');
  }

  // fetch() correctly parses the URL API:
  // hostname = "attacker.com", username = "trusted.com"
  // Request goes to attacker.com — SSRF bypass
  const response = await fetch(inputUrl);
  return response.text();
}

// Also vulnerable: split-on-@ check
function extractHost(url) {
  // "http://trusted.com@attacker.com/" → split('@') → last part includes "attacker.com"
  // But first part "http://trusted.com" matches the allowed pattern — wrong
  const beforeAt = url.split('@')[0].replace(/^https?:\/\//, '');
  return beforeAt; // returns "trusted.com" — attacker wins
}
// FIXED: use URL API consistently for both validation and fetch target
async function proxyFetch(inputUrl) {
  let parsed;
  try {
    parsed = new URL(inputUrl);
  } catch {
    throw new Error('Invalid URL');
  }

  // Reject userinfo in URL — no legitimate use case for credentials in proxy URLs
  if (parsed.username || parsed.password) {
    throw new Error('Credentials in URL not permitted');
  }

  // Validate hostname using the same parser fetch() will use
  const hostname = parsed.hostname;
  if (!ALLOWED_HOSTNAMES.has(hostname)) {
    throw new Error(`Hostname ${hostname} not in allowlist`);
  }

  // Pass the parsed + reconstructed URL to fetch — not the raw input
  const safeUrl = parsed.toString();
  const response = await fetch(safeUrl);
  return response.text();
}
HIGH
SA-SKL-SSRF3-001 — MCP skill validates URLs using string operations (includes, indexOf, split on @) rather than the URL API; an attacker supplies http://trusted.com@attacker.com/path where the string check finds the trusted hostname in the userinfo component but fetch() resolves the actual host as attacker.com. Fix: always use new URL(input).hostname for hostname extraction; reject any URL containing userinfo credentials (parsed.username || parsed.password); pass the URL-API-reconstructed URL to fetch, not the raw input string.

SSRF3-002 — IPv6 localhost bypass

SSRF blocklists commonly check for the string 127.0.0.1 or localhost. IPv6 and alternate IP notations provide many ways to represent loopback and RFC 1918 addresses that bypass such string checks while still resolving to the blocked address. http://[::ffff:127.0.0.1]/admin is an IPv4-mapped IPv6 address that resolves to 127.0.0.1. http://[::1]/admin is the IPv6 loopback. http://0177.0.0.1/ is 127.0.0.1 in octal. http://2130706433/ is 127.0.0.1 as a 32-bit decimal integer. http://0x7f000001/ is the same in hex. The fix is to use a proper IP normalization library rather than string matching.

// VULNERABLE: string-match blocklist misses alternate IP notations
const BLOCKED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0', '::1'];
const BLOCKED_RANGES = ['10.', '172.16.', '192.168.'];

function isBlockedHost(hostname) {
  if (BLOCKED_HOSTS.includes(hostname.toLowerCase())) return true;
  if (BLOCKED_RANGES.some(r => hostname.startsWith(r))) return true;
  return false;
}

// All of these return false (bypass):
// isBlockedHost('[::ffff:127.0.0.1]') → false
// isBlockedHost('[::1]')              → false (not in BLOCKED_HOSTS exactly)
// isBlockedHost('0177.0.0.1')         → false
// isBlockedHost('2130706433')         → false
// isBlockedHost('0x7f000001')         → false
// All resolve to 127.0.0.1 at the TCP layer
// FIXED: normalize IP and check against full RFC 1918 + loopback + link-local ranges
const ipaddr = require('ipaddr.js'); // npm: ipaddr.js

function isPrivateOrLoopback(hostname) {
  // Strip IPv6 brackets
  const raw = hostname.startsWith('[') && hostname.endsWith(']')
    ? hostname.slice(1, -1)
    : hostname;
  let addr;
  try {
    addr = ipaddr.parse(raw); // handles IPv4, IPv6, IPv4-mapped IPv6
  } catch {
    return false; // Not an IP literal — will be resolved by DNS; handle separately
  }
  // ipaddr.js normalizes IPv4-mapped IPv6 to IPv4 for range checks
  const normalized = addr.kind() === 'ipv6' ? addr.toIPv4Address() ?? addr : addr;
  const range = normalized.range();
  // Block loopback, private, link-local, unique-local, reserved
  return ['loopback', 'private', 'linkLocal', 'uniqueLocal',
          'broadcast', 'reserved', 'unspecified'].includes(range);
}

// Use ssrf-req-filter for a battle-tested drop-in:
// const { ssrfFilter } = require('ssrf-req-filter');
// const response = await fetch(url, { agent: ssrfFilter(url) });
HIGH
SA-SKL-SSRF3-002 — MCP skill SSRF blocklist uses string matching against hostnames; IPv6 loopback ([::1]), IPv4-mapped IPv6 ([::ffff:127.0.0.1]), octal (0177.0.0.1), decimal integer (2130706433), and hex (0x7f000001) notations for 127.0.0.1 all bypass the check and resolve to loopback at the TCP layer. Fix: parse IP literals with ipaddr.js and check the normalized range against all blocked categories; use ssrf-req-filter as a drop-in battle-tested solution.

SSRF3-003 — HTTP redirect chain to internal target

When a skill validates the initial URL and then calls fetch() with the default redirect: 'follow' setting, the HTTP client will transparently follow any 3xx redirects returned by the server. If the attacker controls a public server that returns 302 Location: http://169.254.169.254/latest/meta-data/ (the AWS EC2 instance metadata endpoint), the initial URL check passes because the target host is a legitimate public address — but the fetch actually retrieves the cloud metadata endpoint on the internal network. The validation never ran against the redirect target. This is one of the most reliable SSRF techniques against naive validators.

// VULNERABLE: fetch follows 302 redirect to internal target without re-validation
async function fetchWebhook(inputUrl) {
  // Validation checks the initial URL — passes because attacker.com is public
  const { hostname } = new URL(inputUrl);
  if (isPrivateOrLoopback(hostname)) {
    throw new Error('Private addresses not allowed');
  }

  // Default: redirect: 'follow'
  // If attacker.com responds with:
  //   HTTP/1.1 302 Found
  //   Location: http://169.254.169.254/latest/meta-data/iam/security-credentials/
  // fetch() will follow the redirect and return the metadata contents
  // The redirect target was never validated
  const res = await fetch(inputUrl); // ← follows redirect silently
  return res.text();
}
// FIXED: disable automatic redirect following; manually validate each hop
async function fetchWebhook(inputUrl) {
  let currentUrl = inputUrl;
  const MAX_REDIRECTS = 5;

  for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
    const { hostname } = new URL(currentUrl);
    if (isPrivateOrLoopback(hostname)) {
      throw new Error(`Redirect target ${hostname} is a private address`);
    }

    const res = await fetch(currentUrl, {
      redirect: 'manual', // Do NOT follow redirects automatically
    });

    // Not a redirect — return the final response
    if (res.status < 300 || res.status >= 400) {
      return res.text();
    }

    const location = res.headers.get('location');
    if (!location) throw new Error('Redirect with no Location header');

    // Resolve relative Location against the current URL, then re-validate
    currentUrl = new URL(location, currentUrl).toString();
  }

  throw new Error('Too many redirects');
}
CRITICAL
SA-SKL-SSRF3-003 — MCP skill validates the initial URL before fetching but uses fetch() with default redirect: 'follow'; an attacker-controlled public server returns a 302 redirect to an internal address (AWS metadata at 169.254.169.254, Kubernetes API at 10.96.0.1, local services at 127.0.0.1); the redirect target is never validated and the internal response is returned to the attacker. Fix: set redirect: 'manual' and implement a redirect-following loop that re-validates each Location header value against the SSRF blocklist before following.

SSRF3-004 — DNS rebinding via TTL 0

DNS rebinding attacks exploit the gap in time between DNS-based IP validation and the actual TCP connection. The attacker registers a domain under their control and configures their authoritative DNS server to return a public IP address (passing validation) with a TTL of 0. After validation succeeds, the attacker's DNS server switches the response to 127.0.0.1. When the HTTP client resolves the hostname again to establish the TCP connection — which happens after the TTL-0 record expires immediately — it receives the loopback address. The only reliable fix is to pin the IP address returned during the validation DNS lookup and use that pinned IP for the actual connection, bypassing the second DNS resolution entirely.

// VULNERABLE: separate DNS resolution for validation and fetch
const dns = require('dns').promises;

async function safeProxyFetch(inputUrl) {
  const parsed = new URL(inputUrl);
  const hostname = parsed.hostname;

  // First DNS resolution: attacker's DNS returns 1.2.3.4 (public IP) with TTL=0
  const { address } = await dns.lookup(hostname);
  if (isPrivateOrLoopback(address)) {
    throw new Error('Resolved to private IP — blocked');
  }

  // Validation passed. TTL=0 record expires immediately.
  // Attacker's DNS now returns 127.0.0.1.

  // fetch() does its OWN DNS resolution — second lookup returns 127.0.0.1
  // TCP connection goes to loopback — SSRF via DNS rebinding
  const res = await fetch(inputUrl); // ← re-resolves hostname
  return res.text();
}
// FIXED: resolve once, pin the IP, use pinned IP for the actual connection
const dns = require('dns').promises;
const got = require('got'); // npm: got

async function safeProxyFetch(inputUrl) {
  const parsed = new URL(inputUrl);
  const hostname = parsed.hostname;

  // Resolve once and pin the result
  const { address: pinnedIp, family } = await dns.lookup(hostname);
  if (isPrivateOrLoopback(pinnedIp)) {
    throw new Error(`Resolved to private IP ${pinnedIp} — blocked`);
  }

  // Replace hostname with pinned IP, preserve Host header for SNI/vhosts
  // Use got's lookup override so the same resolved IP is used for TCP connect
  const res = await got(inputUrl, {
    dnsLookup: (h, opts, cb) => {
      // Always return the pre-validated pinned IP — no second DNS query
      cb(null, pinnedIp, family);
    },
    headers: { Host: hostname }, // Preserve original hostname for SNI
    followRedirect: false,       // Combine with redirect validation from SSRF3-003
  });
  return res.body;
}
HIGH
SA-SKL-SSRF3-004 — MCP skill resolves the hostname to validate it against an IP blocklist, then passes the original URL to fetch() which performs a second independent DNS lookup; an attacker registers a domain with TTL=0 that resolves to a public IP during validation, then switches DNS to 127.0.0.1 before the fetch connection is established (DNS rebinding). Fix: resolve the hostname once, validate the pinned IP, then use a custom dnsLookup override in got (or equivalent) that always returns the pinned IP for the connection — eliminating the second DNS query that the attacker exploits.

SkillAudit detection summary — SA-SKL-SSRF3

FindingSeverityRoot CauseFix
SSRF3-001HIGHHostname extracted via string split on @ instead of URL API; http://trusted.com@attacker.com/ passes check but resolves to attacker.comUse new URL(input).hostname consistently; reject URLs with userinfo credentials
SSRF3-002HIGHIP blocklist uses string matching; IPv6 loopback, IPv4-mapped IPv6, octal, decimal, and hex IP notations all bypass the checkNormalize IPs with ipaddr.js and check the full range; use ssrf-req-filter drop-in
SSRF3-003CRITICALInitial URL is validated but fetch(redirect: 'follow') follows 302 to internal address without re-checking the redirect targetSet redirect: 'manual'; manually validate each Location header before following
SSRF3-004HIGHDNS resolved separately for validation and for fetch; TTL=0 rebinding switches resolution to 127.0.0.1 between the two callsPin the validated IP; use got dnsLookup override to reuse pinned IP for TCP connect

Related patterns: For basic SSRF patterns in MCP skills that make outbound requests without any URL validation, see SA-SKL-SSRF. For SQL injection via parameterized query bypasses, see SA-SKL-SQLINJ. For XXE and XML parser vulnerabilities in MCP skill request handling, see SA-SKL-XXE.