Claude MCP skill SSRF — webhook delivery retry and error reporting pipeline — SA-SKL-SSRF29
Webhook delivery retry queues and error reporting pipelines re-fetch user-supplied URLs after they were initially validated, creating a window where the URL target can change — via DNS rebinding, Redis manipulation, or redirect chains — to reach internal services. SA-SKL-SSRF29 covers four SSRF patterns in MCP skill registry webhook delivery infrastructure: a retry queue that reads the target URL from Redis without re-validating it, allowing an attacker to modify the Redis entry to point to 169.254.169.254 (IMDS); a DNS rebinding attack on the first retry where the attacker's webhook domain flips to an internal IP between registration validation and retry execution; a TLS certificate fetcher for delivery test reporting that follows the target URL to internal services like Vault; and a webhook delivery audit trail logger that follows HTTP 302 redirects, allowing a redirect chain from an attacker-controlled URL to 169.254.169.254 to log IAM credentials to S3.
169.254.169.254; IMDS response included in failed delivery error log and surfaced in audit report10.0.0.1 between registration validation and first retry, reaching internal Prometheus metricsVault:8200; certificate subject details (internal hostname, org name) included in delivery test reportredirect:follow fetches IMDS via 302 chain from attacker-controlled URL; response body in S3 audit trailBackground: SSRF in webhook delivery retry and error reporting
Webhook delivery systems validate the target URL at registration time and then store it for repeated use across retry cycles. The gap between validation time and use time creates a category of SSRF called "time-of-check to time-of-use" (TOCTOU) — if the URL target can change between the initial validation check and the actual fetch, the validation is bypassed. DNS rebinding is the most reliable TOCTOU exploit: the attacker controls both the webhook domain and its DNS records, so they set a short TTL, pass the validation check with a legitimate public IP, then flip the DNS record to an internal IP before the first retry fires.
SSRF29-001 through SSRF29-004 all share a common root: the SSRF guard is applied once at registration time but not at every subsequent fetch. The fix requires enforcing the full SSRF guard at every fetch — including resolving the hostname to an IP and checking the IP against an RFC1918/link-local/loopback blocklist immediately before each TCP connection is established, so that DNS rebinding between the check and the connect is not possible. The redirect-follow pattern in SSRF29-004 is a frequent oversight: developers enable redirect following for convenience and forget that a redirect can target an internal IP that the original URL's hostname check would have blocked.
Related patterns: SA-SKL-SSRF28, SA-SKL-SSRF27, SA-SKL-CORS27
SSRF29-001: CRITICAL — Retry queue reads target URL from Redis without re-validation
When a webhook delivery fails, the retry worker reads the delivery job from Redis (stored as a serialized JSON object) and re-attempts delivery to the URL stored in the job. The URL is not re-validated against the SSRF guard on retry — only the initial registration endpoint performs the hostname check. An attacker with Redis write access (or via an SSRF that reaches the Redis port) modifies the retry job entry to replace the target URL with http://169.254.169.254/latest/meta-data/iam/security-credentials/prod-role. The retry worker fetches this URL and, when the delivery fails (the IMDS does not return a 200 with a webhook shape), includes the full HTTP response body in the error log — which is surfaced in the audit report shown to the webhook owner.
// VULNERABLE — SSRF29-001
// workers/webhookRetryWorker.js
// BUG: retry reads URL from Redis job without re-validating against SSRF guard
// Attacker modifies Redis entry to 169.254.169.254; IAM creds in error log
async function retryWebhookDelivery(jobId) {
const jobJson = await redis.get(`webhook:retry:${jobId}`);
const job = JSON.parse(jobJson);
// BUG: no SSRF validation on retry — URL trusted from Redis
const { targetUrl, payload, webhookId } = job;
let response;
try {
response = await fetch(targetUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
timeout: 10000,
});
} catch (err) {
// BUG: full error details including response body logged to audit report
await DeliveryLog.record({
webhookId,
targetUrl,
error: err.message,
responseBody: err.responseBody, // ← IAM creds here if IMDS
});
throw err;
}
}
// FIXED — SSRF29-001
// workers/webhookRetryWorker.js
const dns = require('dns').promises;
const ipRangeCheck = require('ip-range-check');
// SSRF guard: resolve hostname and block private/link-local IPs
// Must be called immediately before EVERY fetch, not just at registration
async function validateSsrfGuard(url) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error('Invalid URL in retry job');
}
if (parsed.protocol !== 'https:') {
throw new Error('Only HTTPS webhook URLs are allowed');
}
const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
const addresses6 = await dns.resolve6(parsed.hostname).catch(() => []);
const allAddresses = [...addresses, ...addresses6];
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',
];
for (const ip of allAddresses) {
if (ipRangeCheck(ip, PRIVATE_RANGES)) {
throw new Error(`SSRF blocked: ${parsed.hostname} resolves to private IP ${ip} — SSRF29-001`);
}
}
return parsed;
}
async function retryWebhookDelivery(jobId) {
const jobJson = await redis.get(`webhook:retry:${jobId}`);
const job = JSON.parse(jobJson);
const { targetUrl, payload, webhookId } = job;
// Re-validate SSRF guard on every retry — DNS may have changed since registration
try {
await validateSsrfGuard(targetUrl);
} catch (ssrfErr) {
await DeliveryLog.record({
webhookId,
targetUrl: '[REDACTED]', // never log the blocked URL to report
error: 'Delivery blocked: target URL failed SSRF validation',
blocked: true,
});
throw ssrfErr;
}
let response;
try {
response = await fetch(targetUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
redirect: 'error', // never follow redirects — each redirect could target internal IP
timeout: 10000,
});
} catch (err) {
await DeliveryLog.record({
webhookId,
status: 'failed',
error: err.message.substring(0, 200), // truncate — no response body in error log
});
throw err;
}
}
SSRF29-001 impact: AWS IAM credentials retrieved from IMDS and stored in the webhook delivery error log, which is surfaced to the webhook owner in the audit report UI. With IAM credentials, the attacker can enumerate S3 buckets, read all stored audit reports, access DynamoDB tables, and call any AWS API available to the production role. SkillAudit detects this by identifying webhook retry workers that call fetch() or axios.get() with a URL read from Redis or a job queue without an intervening SSRF guard function call.
SSRF29-002: HIGH — DNS rebinding on first retry reaches internal Prometheus metrics
The webhook error reporting system sends a debug payload to a metrics endpoint constructed by appending /metrics/webhook-error to the base domain of the original webhook URL. The intent is to allow webhook providers to receive structured error metadata. The domain is validated at registration time against a DNS check that blocks RFC1918 addresses. The attacker registers a webhook URL under a domain they control (https://api.attacker.com/webhooks) and sets the domain's DNS TTL to 60 seconds. The initial registration validation resolves api.attacker.com to a legitimate public IP (e.g., 1.2.3.4) and passes the check. Before the first delivery retry fires, the attacker flips the DNS record for api.attacker.com to 10.0.0.1 (internal Prometheus server). The retry worker resolves api.attacker.com fresh (TTL expired), gets 10.0.0.1, and sends the error debug payload to http://10.0.0.1/metrics/webhook-error — which returns the Prometheus metric names, job names, and internal service labels.
// VULNERABLE — SSRF29-002
// workers/webhookRetryWorker.js
// BUG: error reporting constructs internal metrics URL from webhook domain
// DNS rebinding: attacker domain flips to 10.0.0.1 between registration and retry
async function reportDeliveryError(webhookUrl, error, deliveryId) {
const { hostname } = new URL(webhookUrl);
// BUG: assumes hostname validated at registration — DNS can flip between then and now
// No SSRF guard here — fresh DNS resolution at error reporting time
const metricsEndpoint = `https://${hostname}/metrics/webhook-error`;
try {
await fetch(metricsEndpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ deliveryId, error: error.message, timestamp: Date.now() }),
timeout: 5000,
});
} catch {
// ignore metrics send failure
}
}
// FIXED — SSRF29-002
// workers/webhookRetryWorker.js
// Error metrics should be sent to SkillAudit's own internal metrics collector,
// not to an endpoint derived from the user-supplied webhook domain.
// Webhook providers do not need delivery error reports pushed to their domain.
const { registry } = require('./prometheus'); // internal Prometheus registry
async function reportDeliveryError(webhookId, error, deliveryId) {
// Record error metrics internally — never send to user-supplied domain
registry.getMetricAsString('webhook_delivery_errors_total').inc({
webhookId: webhookId.substring(0, 8), // partial ID for cardinality control
errorType: classifyError(error),
});
// Store error details in internal DB for the webhook owner's dashboard
await DeliveryLog.record({
webhookId,
deliveryId,
status: 'failed',
errorType: classifyError(error),
errorMessage: error.message.substring(0, 500),
// No external fetch to user-supplied domain in error reporting path
});
}
function classifyError(error) {
if (error.code === 'ECONNREFUSED') return 'connection_refused';
if (error.code === 'ENOTFOUND') return 'dns_resolution_failed';
if (error.name === 'TimeoutError') return 'timeout';
return 'unknown';
}
SSRF29-002 impact: Internal Prometheus metrics endpoint reached via DNS rebinding, leaking service names, job labels, metric cardinality, and potentially internal hostnames from metric label values. Even read-only access to Prometheus metrics reveals the internal service topology, which attackers use to plan further lateral movement. SkillAudit detects DNS rebinding risk by identifying cases where a hostname from a user-registered URL is re-resolved and used in a fetch without a binding between the validated IP and the connection target (i.e., connecting to the IP directly rather than the hostname after validation).
SSRF29-003: HIGH — TLS certificate fetcher for delivery test reporting reaches internal Vault
The webhook delivery test mode fetches the TLS certificate of the target URL and includes certificate metadata (subject CN, issuer, validity dates, SANs) in the delivery test report to help webhook owners diagnose TLS errors. The implementation opens a TLS connection to the target hostname on port 443 and reads the peer certificate using Node.js tls.connect(). The hostname is taken from the registered webhook URL. An attacker registers a webhook URL pointing to https://vault.internal:8200 — an internal Vault instance. The delivery test mode opens a TLS connection to vault.internal:8200, which may present an internal certificate with the subject CN vault.internal, organization name, and SAN entries that reveal internal service naming conventions. These details are included in the delivery test report returned to the attacker.
// VULNERABLE — SSRF29-003
// services/webhookTestService.js
const tls = require('tls');
// BUG: TLS certificate fetcher connects to user-supplied hostname:port
// Attacker webhook URL points to vault.internal:8200 —
// internal certificate subject details returned in delivery test report
async function fetchTlsCertificate(webhookUrl) {
const { hostname, port } = new URL(webhookUrl);
const certPort = parseInt(port) || 443;
return new Promise((resolve, reject) => {
// BUG: no SSRF guard — connects to any hostname:port
const socket = tls.connect({ host: hostname, port: certPort, rejectUnauthorized: false }, () => {
const cert = socket.getPeerCertificate(true);
socket.end();
resolve({
subject: cert.subject, // ← leaks internal CN, org, department
issuer: cert.issuer,
validFrom: cert.valid_from,
validTo: cert.valid_to,
subjectAltNames: cert.subjectaltname, // ← leaks internal SANs
});
});
socket.on('error', reject);
socket.setTimeout(5000, () => { socket.destroy(); reject(new Error('TLS timeout')); });
});
}
// FIXED — SSRF29-003
// services/webhookTestService.js
const tls = require('tls');
const dns = require('dns').promises;
const ipRangeCheck = require('ip-range-check');
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',
];
async function fetchTlsCertificate(webhookUrl) {
let parsed;
try {
parsed = new URL(webhookUrl);
} catch {
throw new Error('Invalid webhook URL');
}
if (parsed.protocol !== 'https:') {
throw new Error('TLS certificate check requires HTTPS');
}
// Resolve hostname and block private IPs before opening TLS connection
const addresses = await dns.resolve4(parsed.hostname).catch(() => []);
for (const ip of addresses) {
if (ipRangeCheck(ip, PRIVATE_RANGES)) {
throw new Error('TLS certificate check blocked: hostname resolves to private IP — SSRF29-003');
}
}
// Connect to the resolved IP directly to prevent DNS rebinding between resolve and connect
const targetIp = addresses[0];
if (!targetIp) throw new Error('Could not resolve webhook hostname');
const certPort = 443; // only allow standard HTTPS port for TLS cert check
return new Promise((resolve, reject) => {
const socket = tls.connect({
host: targetIp, // connect to IP, not hostname — prevents rebinding
port: certPort,
servername: parsed.hostname, // SNI still uses hostname
rejectUnauthorized: true,
}, () => {
const cert = socket.getPeerCertificate();
socket.end();
// Return only non-sensitive cert metadata
resolve({
issuerOrg: cert.issuer?.O ?? 'unknown',
validFrom: cert.valid_from,
validTo: cert.valid_to,
isValid: socket.authorized,
// subject and SANs omitted — could leak internal naming
});
});
socket.on('error', reject);
socket.setTimeout(5000, () => { socket.destroy(); reject(new Error('TLS timeout')); });
});
}
SSRF29-003 impact: Internal Vault, Consul, or Kubernetes API server TLS certificate details returned in the delivery test report — including subject CN revealing internal hostnames and organization unit naming conventions. Certificate SANs on internal services frequently enumerate all internal service aliases (vault, vault.internal, vault.cluster.local), giving the attacker a map of the internal service topology. SkillAudit detects this by identifying tls.connect() or https.request() calls where the hostname is derived from a user-registered URL without a preceding DNS resolution + private-IP block check.
SSRF29-004: HIGH — Delivery audit trail logger follows redirects to IMDS
The webhook delivery audit trail writes the full HTTP response body from the webhook target to an S3 object for compliance logging. The implementation uses node-fetch with redirect: 'follow' (the default). An attacker registers a webhook URL at https://redirect.example.com/to-imds — a server they control that returns HTTP/1.1 302 Found with Location: http://169.254.169.254/latest/meta-data/iam/security-credentials/prod-role. The initial SSRF validation checks redirect.example.com and finds a valid public IP. When the delivery worker fires, node-fetch follows the 302 redirect to http://169.254.169.254/..., receives the IAM role credentials JSON, and writes the full response body to the S3 audit trail object at s3://skillaudit-audit-logs/webhooks/{webhookId}/{deliveryId}.json. The S3 object is accessible to anyone with read access to the audit logs bucket.
// VULNERABLE — SSRF29-004
// workers/webhookDeliveryWorker.js
// BUG: redirect:follow (default) allows 302 → 169.254.169.254 chain
// Initial SSRF guard checks the original URL only —
// redirect target is not validated → IAM creds written to S3 audit trail
async function deliverWebhook(webhookId, targetUrl, payload) {
const response = await fetch(targetUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
// BUG: redirect:follow is the default — 302 to 169.254.169.254 not blocked
});
const responseBody = await response.text();
// BUG: full response body logged to S3 — includes IMDS IAM creds if redirect followed
await s3.putObject({
Bucket: 'skillaudit-audit-logs',
Key: `webhooks/${webhookId}/${Date.now()}.json`,
Body: JSON.stringify({
webhookId,
targetUrl,
status: response.status,
responseBody, // ← IAM creds here if redirect to IMDS was followed
}),
}).promise();
}
// FIXED — SSRF29-004
// workers/webhookDeliveryWorker.js
async function deliverWebhook(webhookId, targetUrl, payload) {
// Re-validate SSRF guard immediately before fetch (see SSRF29-001 fix)
await validateSsrfGuard(targetUrl);
const response = await fetch(targetUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
redirect: 'error', // never follow redirects — each redirect could target internal IP
timeout: 10000,
});
// Log only delivery metadata to S3 — never the response body
// Response body from webhook target may contain sensitive data or be very large
await s3.putObject({
Bucket: 'skillaudit-audit-logs',
Key: `webhooks/${webhookId}/${Date.now()}.json`,
Body: JSON.stringify({
webhookId,
targetUrlHash: crypto.createHash('sha256').update(targetUrl).digest('hex'),
status: response.status,
deliveredAt: new Date().toISOString(),
// responseBody intentionally omitted — prevents data exfil via redirect chain
}),
}).promise();
}
SSRF29-004 impact: AWS IAM credentials written to the S3 audit log bucket via a redirect chain, accessible to any AWS identity with read access to the audit logs bucket. The credentials are stored persistently until the S3 object expires (typically 90 days under compliance retention), giving the attacker an extended window to use them. The redirect-follow pattern is the most common SSRF vector in webhook delivery systems because developers assume the initial URL validation is sufficient; the fix is redirect: 'error' on every fetch in the delivery pipeline. SkillAudit detects this by identifying fetch() or axios calls in webhook delivery workers that use the default redirect behavior (follow) rather than redirect: 'error' or maxRedirects: 0.
Detection with SkillAudit
SkillAudit's static analysis scans webhook delivery retry and error reporting pipelines for all four SA-SKL-SSRF29 patterns. For SSRF29-001 it identifies retry worker fetch calls that read the target URL from Redis or a job queue without a preceding SSRF guard function call. For SSRF29-002 it identifies error reporting code that constructs a fetch URL by appending a path to the hostname of a user-registered URL, flagging this as a DNS rebinding risk when the hostname is re-resolved at error time. For SSRF29-003 it identifies tls.connect() calls where the hostname is from a user-registered URL without a preceding private-IP DNS check. For SSRF29-004 it identifies fetch() calls in delivery workers that use the default redirect: 'follow' behavior rather than redirect: 'error'.
| Finding | Severity | Root cause | Fix |
|---|---|---|---|
| SSRF29-001 | Critical | Retry worker reads target URL from Redis without re-validating — DNS may have changed since registration; attacker with Redis write access replaces URL with 169.254.169.254; IAM creds in error log | Re-validate SSRF guard (DNS resolve + private-IP block) on every retry; never log response body in error records; redirect: 'error' |
| SSRF29-002 | High | Error reporting derives metrics URL from webhook domain — DNS rebinding between registration and retry; attacker domain flips to internal Prometheus 10.0.0.1 | Never send error reports to user-supplied domains; use internal metrics collector only |
| SSRF29-003 | High | TLS certificate fetcher opens connection to user-supplied hostname:port — attacker registers vault.internal:8200; internal cert subject details in delivery test report | Resolve hostname to IP, block private ranges, connect to IP not hostname; strip SAN and subject from cert metadata returned to user |
| SSRF29-004 | High | Delivery logger follows 302 redirects — attacker webhook 302 → 169.254.169.254; IAM creds written to S3 audit trail | redirect: 'error' on all delivery fetches; never log response body to audit trail; re-validate SSRF guard on every fetch |
Related findings: SA-SKL-SSRF28, SA-SKL-SSRF27, SA-SKL-CORS27
Scan your MCP skill registry for SA-SKL-SSRF29. SkillAudit scans your MCP skill registry for all SA-SKL-SSRF29 patterns — retry queue URL re-use without re-validation, DNS rebinding on error reporting, TLS certificate fetcher SSRF, and redirect-follow IAM credential exfil — and delivers a prioritized fix report in minutes. Get started →