← Blog

Claude skill SSRF via DNS rebinding, redirect chains, IPv6-mapped addresses and 0.0.0.0 in MCP skills — SA-SKL-SSRF11

Server-Side Request Forgery in MCP skills is commonly addressed by resolving the target URL's hostname and rejecting RFC1918 IP ranges before making the request. SA-SKL-SSRF11 covers four techniques that bypass this naive IP-check approach: DNS rebinding with a TTL-0 record that maps to a public IP at validation time and a private IP milliseconds later at fetch time; an HTTP redirect chain where the initial URL resolves to a public IP but a 301 redirect leads to an internal service; IPv4-mapped IPv6 addresses like ::ffff:192.168.1.1 that contain a private IPv4 address but are not matched by range checks that only cover IPv4 notation; and the special address 0.0.0.0 which resolves to the local host on most Linux and macOS systems but is not an RFC1918 address and therefore passes most blocklists. Each of these bypasses can reach internal metadata services, admin panels, or database management interfaces that should not be reachable from user-controlled URLs.

By SkillAudit  |  8 Nov 2026

Why IP-allowlist checks at resolve time fail against DNS rebinding

The fundamental flaw in pre-fetch DNS validation is the time-of-check vs. time-of-use (TOCTOU) gap. The validation step resolves the hostname and checks the IP, but the fetch step resolves the hostname again (via the OS DNS resolver which may have evicted the cache entry if TTL was 0). An attacker controls the authoritative DNS server for a subdomain, initially returns a public IP like 1.2.3.4 with TTL 0, then changes the DNS record to 192.168.1.1. The validation step sees 1.2.3.4 (public, allowed) and the fetch step sees 192.168.1.1 (internal). The only reliable fix is to validate the IP at the socket connection level — after the OS has resolved the hostname and established the connection — where the actual target IP is known and cannot change between check and use.

SA-SKL-SSRF11 findings at a glance
CRITICALSSRF11-001 — DNS rebinding with TTL 0 — IP check passes on first resolution (public IP); fetch uses second resolution (private IP); TOCTOU gap exploited
CRITICALSSRF11-002 — IP check validates initial URL hostname; fetch follows HTTP 301 redirect to private IP; redirect destination not re-validated
HIGHSSRF11-003 — RFC1918 check covers IPv4 only; http://[::ffff:192.168.1.1]/ is IPv4-mapped IPv6 that bypasses the check and reaches private hosts
HIGHSSRF11-004 — 0.0.0.0 not in RFC1918 ranges; passes IP blocklist; resolves to localhost on Linux/macOS; reaches local services on port

SSRF11-001 — DNS rebinding with TTL 0 defeats pre-fetch IP validation

An attacker who controls an authoritative DNS server can set TTL 0 on a subdomain record, forcing the resolver to discard the cached entry immediately after each lookup. The attack sequence: (1) attacker controls evil.attacker.com DNS with TTL 0; (2) first lookup returns 1.2.3.4 (a public IP the attacker also controls as a web server that returns HTTP 200); (3) skill validates 1.2.3.4 — public, passes RFC1918 check; (4) a few hundred milliseconds pass while the validation result propagates back and the fetch is initiated; (5) attacker's DNS flips the record to 192.168.1.1; (6) the fetch step resolves the hostname again (TTL 0, no cache) and gets 192.168.1.1; (7) HTTP request reaches the internal service. The only reliable fix is a custom HTTP agent that overrides socket-level connection and validates the resolved IP address at connect time, after DNS resolution but before the TCP handshake.

// VULNERABLE — IP check at resolve time; DNS rebinding exploits TOCTOU gap
import dns from 'dns/promises';
import fetch from 'node-fetch';

const PRIVATE_RANGES = [
  /^10\./,
  /^172\.(1[6-9]|2\d|3[01])\./,
  /^192\.168\./,
  /^127\./,
  /^169\.254\./,
];

async function isSafeUrl(urlStr) {
  const url = new URL(urlStr);
  if (!['http:', 'https:'].includes(url.protocol)) return false;
  const addresses = await dns.resolve4(url.hostname);
  // VULNERABLE: check happens here, but fetch resolves DNS again milliseconds later
  for (const addr of addresses) {
    if (PRIVATE_RANGES.some(r => r.test(addr))) return false;
  }
  return true;
}

app.post('/api/audit', authenticate, async (req, res) => {
  const { repoUrl } = req.body;
  if (!await isSafeUrl(repoUrl)) {
    return res.status(400).json({ error: 'Invalid URL' });
  }
  // VULNERABLE: second DNS resolution here may return a different IP
  const response = await fetch(repoUrl);
  // ... process response
});
// FIXED — custom HTTP agent validates IP at socket connect time (post-DNS-resolution)
import net from 'net';
import http from 'http';
import https from 'https';
import fetch from 'node-fetch';

const PRIVATE_RANGES = [
  /^10\./,
  /^172\.(1[6-9]|2\d|3[01])\./,
  /^192\.168\./,
  /^127\./,
  /^169\.254\./,
  /^0\.0\.0\.0$/,
  /^::1$/,
  /^::ffff:(?:10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|127\.|169\.254\.)/i,
];

function isPrivateIp(ip) {
  return PRIVATE_RANGES.some(r => r.test(ip));
}

function makeSafeAgent(AgentClass) {
  return new AgentClass({
    // Override createConnection to intercept the resolved IP before TCP connect
    lookup: (hostname, options, callback) => {
      require('dns').lookup(hostname, options, (err, address, family) => {
        if (err) return callback(err);
        // FIXED: validate IP at resolve time AND block before connection is made
        if (isPrivateIp(address)) {
          return callback(new Error(`SSRF blocked: private IP ${address} for ${hostname}`));
        }
        callback(null, address, family);
      });
    },
  });
}

const safeHttpAgent = makeSafeAgent(http.Agent);
const safeHttpsAgent = makeSafeAgent(https.Agent);

app.post('/api/audit', authenticate, async (req, res) => {
  const { repoUrl } = req.body;
  let url;
  try {
    url = new URL(repoUrl);
    if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid protocol');
  } catch {
    return res.status(400).json({ error: 'Invalid URL' });
  }

  try {
    const agent = url.protocol === 'https:' ? safeHttpsAgent : safeHttpAgent;
    const response = await fetch(repoUrl, {
      agent,
      redirect: 'error', // also block redirect chains (see SSRF11-002)
      timeout: 10_000,
    });
    // ... process response
  } catch (err) {
    if (err.message.startsWith('SSRF blocked')) {
      return res.status(400).json({ error: 'URL resolves to a private address' });
    }
    throw err;
  }
});

SSRF11-002 — HTTP redirect chain leads to private IP after allowlist check

When a skill validates the URL hostname before fetching and then follows HTTP redirects during the fetch, the redirect target is a different URL that was never validated. An attacker can register a public domain, configure it to return an HTTP 301 to http://192.168.1.1/admin, and submit the public domain URL to the skill. The validation checks the public domain (safe), the fetch follows the redirect to the private IP (unsafe). The fix is either to disable redirect following entirely with redirect: 'error' in node-fetch and reject any URL that redirects, or to implement a custom redirect handler that re-validates the destination URL at each hop before following it.

// VULNERABLE — redirect following not disabled; redirect to private IP bypasses check
import fetch from 'node-fetch';

async function fetchAuditTarget(url) {
  // VULNERABLE: follow:'follow' (default) follows 301/302/307/308 redirects
  // Initial URL validated, redirect destination is not
  const response = await fetch(url, {
    timeout: 10_000,
    // redirect: 'follow' is the default — attacker redirects to 192.168.1.1
  });
  return response.text();
}
// FIXED — redirect:'error' rejects all redirects; or manual redirect with re-validation
import fetch from 'node-fetch';

async function fetchAuditTarget(url) {
  // OPTION A: reject all redirects — simplest and safest for most use cases
  const response = await fetch(url, {
    redirect: 'error', // throws FetchError if server sends a redirect
    timeout: 10_000,
    agent: makeSafeAgentForUrl(url), // socket-level IP check from SSRF11-001
  });
  return response.text();
}

// OPTION B: allow up to N redirects but re-validate each destination
async function fetchWithSafeRedirect(urlStr, maxRedirects = 3) {
  let currentUrl = urlStr;
  for (let hop = 0; hop <= maxRedirects; hop++) {
    const response = await fetch(currentUrl, {
      redirect: 'manual', // get redirect without following
      timeout: 10_000,
      agent: makeSafeAgentForUrl(currentUrl), // validates IP at socket-connect time
    });
    if (response.status >= 300 && response.status < 400) {
      const location = response.headers.get('location');
      if (!location) throw new Error('Redirect with no Location header');
      // Re-validate redirect destination before following
      const nextUrl = new URL(location, currentUrl).toString();
      currentUrl = nextUrl; // agent will re-validate the new hostname on next iteration
      if (hop === maxRedirects) throw new Error('Too many redirects');
      continue;
    }
    return response.text();
  }
}

SSRF11-003 — IPv4-mapped IPv6 addresses bypass RFC1918 range checks

IPv4-mapped IPv6 addresses are a notation in which an IPv4 address is embedded in an IPv6 address using the prefix ::ffff:. For example, the private IPv4 address 192.168.1.1 can be written as the IPv6 address ::ffff:192.168.1.1 or in hex as ::ffff:c0a8:0101. When an MCP skill's SSRF check tests only against the standard IPv4 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) using IPv4-format regular expressions, the check passes for http://[::ffff:192.168.1.1]/ because the address does not match the IPv4 patterns. The underlying OS and HTTP library may then resolve the IPv6 address and connect to the private host. The fix is to normalize IPv6-mapped IPv4 addresses to their IPv4 canonical form before the range check, and to add IPv6 loopback (::1) and unspecified (::) to the blocklist.

// VULNERABLE — RFC1918 check covers IPv4 notation only; IPv6-mapped IPv4 bypasses it
function isPrivateIp(ip) {
  // VULNERABLE: only checks standard IPv4 private ranges
  // http://[::ffff:192.168.1.1]/ passes this check
  const privateRanges = [
    /^10\./,
    /^172\.(1[6-9]|2\d|3[01])\./,
    /^192\.168\./,
    /^127\./,
    /^169\.254\./,
  ];
  return privateRanges.some(r => r.test(ip));
}
// FIXED — normalize IPv6-mapped IPv4 to IPv4 form before range check
import { isIPv4, isIPv6 } from 'net';

function normalizeIp(ip) {
  // Handle IPv6 addresses in bracket notation from URL parsing
  const stripped = ip.replace(/^\[|\]$/g, '');

  // Normalize IPv4-mapped IPv6: ::ffff:192.168.1.1 -> 192.168.1.1
  const ipv4MappedMatch = stripped.match(
    /^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i
  );
  if (ipv4MappedMatch) return ipv4MappedMatch[1];

  // Normalize ::ffff:c0a8:0101 (hex-notation IPv4-mapped IPv6)
  const ipv4MappedHexMatch = stripped.match(/^::ffff:([0-9a-f]{4}):([0-9a-f]{4})$/i);
  if (ipv4MappedHexMatch) {
    const [, hi, lo] = ipv4MappedHexMatch;
    const a = parseInt(hi.slice(0, 2), 16);
    const b = parseInt(hi.slice(2, 4), 16);
    const c = parseInt(lo.slice(0, 2), 16);
    const d = parseInt(lo.slice(2, 4), 16);
    return `${a}.${b}.${c}.${d}`;
  }

  return stripped;
}

function isPrivateOrSpecialIp(rawIp) {
  const ip = normalizeIp(rawIp);

  // IPv6 loopback, unspecified, and link-local
  if (['::1', '::', '::0', 'fe80::1'].includes(ip.toLowerCase())) return true;
  if (/^fe80:/i.test(ip)) return true;

  // IPv4 private and special ranges
  const privateRanges = [
    /^10\./,
    /^172\.(1[6-9]|2\d|3[01])\./,
    /^192\.168\./,
    /^127\./,
    /^169\.254\./,
    /^0\.0\.0\.0$/,         // SSRF11-004: 0.0.0.0
    /^0\./,                  // 0.x.x.x block
  ];
  return privateRanges.some(r => r.test(ip));
}

SSRF11-004 — 0.0.0.0 bypasses RFC1918 blocklist and resolves to localhost

The address 0.0.0.0 is defined in RFC 1122 as the unspecified address and is not part of any RFC1918 private range (10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16). Many SSRF blocklists check only the three RFC1918 ranges and 127.0.0.0/8 (loopback), so they pass 0.0.0.0. On Linux and macOS, connecting to port 80 at 0.0.0.0 routes to the loopback interface — it reaches whatever is listening on that port on localhost. If an MCP skill runs alongside a database management interface, an internal admin panel, or a Redis instance on a non-standard port, connecting to http://0.0.0.0:6379/ would reach Redis. The fix is to add 0.0.0.0 and the entire 0.0.0.0/8 block to the SSRF blocklist explicitly.

// VULNERABLE — blocklist omits 0.0.0.0; curl http://0.0.0.0:6379/ reaches Redis on localhost
function isPrivateIp(ip) {
  // VULNERABLE: 0.0.0.0 not in any of these ranges
  return (
    /^10\./.test(ip) ||
    /^172\.(1[6-9]|2\d|3[01])\./.test(ip) ||
    /^192\.168\./.test(ip) ||
    /^127\./.test(ip) ||
    /^169\.254\./.test(ip)
    // MISSING: 0.0.0.0 check
  );
}
// FIXED — comprehensive blocklist including 0.0.0.0/8, link-local, cloud metadata
function isPrivateOrSpecialIp(ip) {
  const normalized = normalizeIp(ip); // from SSRF11-003 fix above

  const blocked = [
    /^10\./,                           // RFC1918 Class A private
    /^172\.(1[6-9]|2\d|3[01])\./,     // RFC1918 Class B private
    /^192\.168\./,                     // RFC1918 Class C private
    /^127\./,                          // IPv4 loopback (127.0.0.0/8)
    /^169\.254\./,                     // Link-local / APIPA
    /^0\./,                            // 0.0.0.0/8 — includes 0.0.0.0
    /^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./, // RFC6598 shared address space
    /^192\.0\.2\./,                    // TEST-NET-1
    /^198\.(1[89])\./,                 // TEST-NET-3
    /^203\.0\.113\./,                  // TEST-NET-3 documentation
    /^240\./,                          // Reserved (future use)
    /^255\.255\.255\.255$/,            // Broadcast
    /^::1$/,                           // IPv6 loopback
    /^::/,                             // IPv6 unspecified
    /^fe80:/i,                         // IPv6 link-local
    /^fc00:/i,                         // IPv6 unique local
  ];

  return blocked.some(r => r.test(normalized));
}

Related patterns: For the basic SSRF patterns in webhook URL handling and scheduled job fetching, see SA-SKL-SSRF10. The headless browser and PDF renderer SSRF variants (where the user-agent is a browser that follows redirects automatically) are covered in SA-SKL-SSRF9. For redirect-chain attacks in OAuth flows specifically, see SA-SKL-REDIRECT5.

FindingSeverityVulnerable patternFix
SSRF11-001CriticalDNS resolved at check time; fetch re-resolves milliseconds later after TTL-0 rebind to private IPCustom HTTP agent with lookup override; validate IP at socket connect time, not before fetch
SSRF11-002CriticalInitial URL resolves to public IP (checked); HTTP 301 redirect leads to 192.168.x.x (not checked)redirect: 'error' in node-fetch to block all redirects; or re-validate each hop's destination IP
SSRF11-003Highhttp://[::ffff:192.168.1.1]/ — IPv4-mapped IPv6; RFC1918 regex check only covers IPv4 notationNormalize ::ffff:x.x.x.x to IPv4 canonical form before range check; add IPv6 loopback and link-local to blocklist
SSRF11-004High0.0.0.0 passes RFC1918 check; connects to localhost on Linux/macOS; reaches services on arbitrary portsAdd 0.0.0.0/8 block (/^0\./) to SSRF blocklist; include cloud metadata ranges and RFC6598 shared space