SA-SKL-SSRF34 — Server-Side Request Forgery
SSRF in MCP skill external integration and third-party service connection endpoints
MCP skills that connect to external services — GitHub, Jira, Slack, and custom notification endpoints — frequently accept base URLs or webhook URLs directly from user input. When those URLs are fetched server-side without validation, an attacker redirects the skill's HTTP client to internal infrastructure, AWS instance metadata, or monitoring services. SA-SKL-SSRF34 documents four such vulnerabilities across common third-party integration patterns, including cases where full response bodies from internal services are persisted to the application database.
githubApiUrl; IAM credentials from AWS metadata error response logged to audit trail and stored in DB.
jiraBaseUrl; Prometheus metrics JSON stored as Jira ticket description in DB.
slackWebhookUrl; POST body interpreted as InfluxDB line protocol writing arbitrary internal metrics.
notifyUrl; Kibana REST API index mapping returned and stored as notification response in DB.
SSRF34-001 — GitHub Enterprise API URL accepts internal AWS metadata endpoint
The GitHub integration exposes a githubApiUrl configuration field to allow GitHub Enterprise Server customers to point the skill at their self-hosted instance. The skill constructs API requests using this value directly without validating the hostname or IP range. When the API call fails — for example, because 169.254.169.254 returns a JSON-shaped response that does not match the GitHub API schema — the full HTTP response body is included in the structured error object that gets written to the audit log table.
An attacker who can set githubApiUrl (via tenant configuration, an MCP tool call, or a misconfigured admin panel) points it at the AWS EC2 instance metadata service at http://169.254.169.254/latest/meta-data/iam/security-credentials/. The metadata endpoint returns a credential document containing AccessKeyId, SecretAccessKey, and Token. The skill logs this as an error response body, persisting live IAM credentials to the audit trail database row that is later surfaced in the SkillAudit dashboard and potentially exported.
// VULNERABLE — SSRF34-001
// GitHub integration: user-supplied githubApiUrl used without validation
async function fetchGitHubUser(githubApiUrl, username, token) {
const url = `${githubApiUrl}/users/${username}`;
let response;
try {
response = await fetch(url, {
headers: { Authorization: `token ${token}` },
});
} catch (err) {
// Full error including any response body written to audit log
await db.auditLog.create({
event: 'github_api_error',
detail: { url, error: err.message, body: err.responseBody },
});
throw err;
}
const body = await response.text();
if (!response.ok) {
// Non-2xx response body (may contain IAM creds from metadata endpoint)
await db.auditLog.create({
event: 'github_api_failure',
detail: { url, status: response.status, body },
});
throw new Error(`GitHub API error ${response.status}`);
}
return JSON.parse(body);
}
Fix for SSRF34-001: Maintain an explicit allowlist of known GitHub SaaS hostnames (api.github.com) and user-registered GitHub Enterprise hostnames stored in your tenant configuration table. Before making any outbound request, parse the URL with new URL(), resolve the hostname to its IP addresses, and reject any address in RFC-1918 private ranges (10/8, 172.16/12, 192.168/16) and the link-local range (169.254/16). Strip all response body content from audit log entries — log only the HTTP status code and a fixed error label, never the raw body. GitHub API error responses in legitimate scenarios never need to be persisted verbatim.
// FIXED — SSRF34-001
import dns from 'node:dns/promises';
import { isPrivateIP } from './ip-utils.js'; // checks RFC-1918 + 169.254/16
const GITHUB_ALLOWLIST = new Set(['api.github.com']);
async function validateGitHubUrl(raw) {
const parsed = new URL(raw); // throws on malformed
if (parsed.protocol !== 'https:') throw new Error('Only HTTPS allowed');
if (!GITHUB_ALLOWLIST.has(parsed.hostname) && !isTenantGHE(parsed.hostname)) {
throw new Error(`Host not in allowlist: ${parsed.hostname}`);
}
const { address } = await dns.lookup(parsed.hostname);
if (isPrivateIP(address)) throw new Error('Resolved to private IP');
return parsed;
}
async function fetchGitHubUser(githubApiUrl, username, token) {
const parsed = await validateGitHubUrl(githubApiUrl);
const url = `${parsed.origin}/users/${username}`;
const response = await fetch(url, { headers: { Authorization: `token ${token}` } });
if (!response.ok) {
// Log only status — never the response body
await db.auditLog.create({ event: 'github_api_failure', detail: { status: response.status } });
throw new Error(`GitHub API error ${response.status}`);
}
return response.json();
}
SSRF34-002 — Jira base URL enables internal Prometheus scraping
The Jira integration accepts a jiraBaseUrl value from the skill configuration to construct REST API calls for ticket creation. The skill appends paths like /rest/api/3/issue to this base URL and POST-requests them with Jira credentials. When ticket creation returns a non-2xx response, the response body — including whatever was returned by the internal server at that URL — is stored as the ticket description in the application database for later retrieval.
An attacker who controls jiraBaseUrl sets it to http://prometheus.internal:9090. The skill constructs http://prometheus.internal:9090/rest/api/3/issue, which Prometheus ignores and returns its full metrics page as the HTTP response body. Since Prometheus returns JSON-shaped data for many endpoints, the skill may partially parse this or store it wholesale as the ticket description in the DB, exposing internal metric names, job names, label values, and counter values to anyone with read access to the ticket store.
// VULNERABLE — SSRF34-002
// Jira integration: user-supplied jiraBaseUrl used without host validation
async function createJiraTicket(jiraBaseUrl, credentials, ticketData) {
const url = `${jiraBaseUrl}/rest/api/3/issue`;
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Basic ${Buffer.from(
`${credentials.user}:${credentials.token}`
).toString('base64')}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(ticketData),
});
const body = await response.text();
if (!response.ok) {
// Response body from arbitrary internal host stored as ticket description
await db.tickets.create({ description: body, status: 'error', url });
throw new Error('Jira ticket creation failed');
}
return JSON.parse(body);
}
Fix for SSRF34-002: Store Jira base URLs in a tenant configuration table at setup time and validate them against DNS when saved — not at request time. At request time, look up the pre-validated hostname from the DB rather than accepting it from the incoming MCP tool call. Additionally perform DNS-based private-IP blocking before each outbound request to catch TTL-based DNS rebinding attacks. Enforce that the response Content-Type header is application/json and that the response body matches the expected Jira issue creation schema (contains id and key fields) before persisting anything. Never store raw error response bodies — record only the HTTP status and a boolean error flag.
// FIXED — SSRF34-002
import { resolveDnsAndBlockPrivate } from './ssrf-guard.js';
async function getValidatedJiraOrigin(tenantId) {
// Base URL was validated and DNS-checked at configuration save time
const cfg = await db.tenantConfig.findOne({ tenantId });
// Re-check DNS to block rebinding: throws if internal address
await resolveDnsAndBlockPrivate(new URL(cfg.jiraBaseUrl).hostname);
return cfg.jiraBaseUrl;
}
async function createJiraTicket(tenantId, credentials, ticketData) {
const baseUrl = await getValidatedJiraOrigin(tenantId);
const url = `${baseUrl}/rest/api/3/issue`;
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Basic ${Buffer.from(
`${credentials.user}:${credentials.token}`
).toString('base64')}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(ticketData),
});
if (!response.ok) {
// Never store body — log status only
await db.auditLog.create({ event: 'jira_error', detail: { status: response.status } });
throw new Error(`Jira API error ${response.status}`);
}
const json = await response.json();
if (!json.id || !json.key) throw new Error('Unexpected Jira response shape');
return json;
}
SSRF34-003 — Slack webhook URL test writes to internal InfluxDB
The Slack integration provides a "test webhook" feature that sends a POST request to the configured slackWebhookUrl with a fixed JSON payload to verify connectivity. The URL is taken directly from the user-supplied integration configuration and fetched without host validation. The fixed test payload sent in the POST body is {"text":"SkillAudit webhook test"}, which is a valid UTF-8 string that can be interpreted by other HTTP servers.
An attacker sets slackWebhookUrl to http://influxdb.internal:8086/write?db=metrics. The skill POSTs {"text":"SkillAudit webhook test"} to that URL. InfluxDB's line protocol write endpoint accepts arbitrary UTF-8 and interprets the JSON as a malformed but partially valid line protocol entry. With a crafted payload — attacker changes the test message via another skill parameter — the attacker can write arbitrary measurements to the internal InfluxDB instance, corrupting monitoring data or causing alert storms in internal dashboards.
// VULNERABLE — SSRF34-003
// Slack integration: user-supplied slackWebhookUrl tested without validation
async function testSlackWebhook(slackWebhookUrl, testMessage) {
const payload = JSON.stringify({
text: testMessage || 'SkillAudit webhook test',
});
const response = await fetch(slackWebhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: payload,
// Follows redirects by default — attacker can chain via open redirect
redirect: 'follow',
});
return {
success: response.ok,
status: response.status,
body: await response.text(),
};
}
Fix for SSRF34-003: Restrict slackWebhookUrl to the hooks.slack.com domain only — parse the URL with new URL(), assert parsed.hostname === 'hooks.slack.com', and assert parsed.protocol === 'https:' before making any network call. Set redirect: 'error' in the fetch options so that open-redirect chains are blocked at the HTTP layer. The test payload must be a fixed constant defined in code — never interpolated from user input. Return only a success boolean to the caller; never return the response body, which may contain data from an internal service if the URL was misconfigured.
// FIXED — SSRF34-003
const SLACK_WEBHOOK_HOST = 'hooks.slack.com';
// Fixed constant — never interpolated from user input
const TEST_PAYLOAD = JSON.stringify({ text: 'SkillAudit webhook connectivity test' });
function validateSlackWebhookUrl(raw) {
const parsed = new URL(raw); // throws on malformed
if (parsed.protocol !== 'https:') {
throw new Error('Slack webhook URL must use HTTPS');
}
if (parsed.hostname !== SLACK_WEBHOOK_HOST) {
throw new Error(`Slack webhook host must be ${SLACK_WEBHOOK_HOST}`);
}
return parsed.href;
}
async function testSlackWebhook(slackWebhookUrl) {
const validatedUrl = validateSlackWebhookUrl(slackWebhookUrl);
const response = await fetch(validatedUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: TEST_PAYLOAD,
redirect: 'error', // block redirect chains
});
// Return only boolean — no response body exposed
return { success: response.ok };
}
SSRF34-004 — Custom notification URL reads internal Kibana index mappings
The skill supports a custom notification endpoint via a user-supplied notifyUrl. When a skill execution completes, the runtime sends a GET request to this URL and stores the HTTP response body in the notification_callbacks table as the "notification response" for auditing and debugging purposes. This design means that whatever the server at notifyUrl returns — including JSON from internal infrastructure — is persisted to the database.
An attacker who can supply notifyUrl targets http://kibana.internal:5601/api/index_patterns/index_pattern. The Kibana REST API returns a full JSON document listing all index pattern fields, including index names that reveal internal log structure, service names, and environment labels. This document is stored verbatim in the notification_callbacks table where any tenant admin or SkillAudit dashboard user can retrieve it, exposing the internal observability architecture to unauthorized parties.
// VULNERABLE — SSRF34-004
// Notification callback: user-supplied notifyUrl fetched and response stored
async function sendNotification(notifyUrl, executionId, result) {
const url = new URL(notifyUrl);
url.searchParams.set('executionId', executionId);
url.searchParams.set('status', result.status);
const response = await fetch(url.toString(), {
method: 'GET',
signal: AbortSignal.timeout(5000),
});
const responseBody = await response.text();
// Full response body from arbitrary internal service stored in DB
await db.notificationCallbacks.create({
executionId,
notifyUrl,
responseStatus: response.status,
responseBody, // attacker reads this later via dashboard API
createdAt: new Date(),
});
return { delivered: response.ok };
}
Fix for SSRF34-004: Apply DNS-based private-IP blocking before every outbound notification request. Set redirect: 'error' to block redirect-chain attacks. Never store the response body — record only the HTTP status code and a delivered boolean derived from whether the status was 2xx. If callers need proof-of-delivery, store only the status code. Add a size assertion: legitimate notification receivers return a minimal acknowledgment (often empty or {"ok":true}) — reject responses larger than 1 KB or with unexpected content types before they touch the database.
// FIXED — SSRF34-004
import { resolveDnsAndBlockPrivate } from './ssrf-guard.js';
async function sendNotification(notifyUrl, executionId, result) {
const parsed = new URL(notifyUrl);
if (!['http:', 'https:'].includes(parsed.protocol)) {
throw new Error('notifyUrl must use http or https');
}
// Block private IPs — throws if internal address
await resolveDnsAndBlockPrivate(parsed.hostname);
const url = new URL(notifyUrl);
url.searchParams.set('executionId', executionId);
url.searchParams.set('status', result.status);
const response = await fetch(url.toString(), {
method: 'GET',
redirect: 'error',
signal: AbortSignal.timeout(5000),
});
// Store only delivery status — never the response body
await db.notificationCallbacks.create({
executionId,
responseStatus: response.status,
delivered: response.ok,
createdAt: new Date(),
});
return { delivered: response.ok };
}
Compound attack chain
These four vulnerabilities compose into a staged internal reconnaissance attack. An attacker first exploits SSRF34-004 (notification URL) to map internal hostnames by cycling through common internal DNS names and observing which return 2xx status codes versus connection errors — the boolean delivery result leaks reachability even without the response body. With a confirmed list of live internal hosts, the attacker uses SSRF34-001 (GitHub API URL) against a confirmed internal endpoint to retrieve and persist full response bodies via the audit log. If the initial metadata endpoint hit yields IAM credentials, those credentials can be used to escalate outside the VPC entirely. SSRF34-002 and SSRF34-003 widen the blast radius: Prometheus endpoint enumeration via SSRF34-002 reveals service names and label values that map the internal microservice topology, while SSRF34-003's InfluxDB write capability introduces metric corruption that can mask the attack by triggering false-positive alerts and obscuring anomaly-detection signals during the breach.
Detection with SkillAudit tree-sitter queries
; SA-SKL-SSRF34 Query 1 — Detect user-supplied URL passed directly to fetch()
; Matches patterns where a parameter named *Url, *BaseUrl, or *WebhookUrl
; flows into fetch() without an intervening validation call
(call_expression
function: (identifier) @fn (#eq? @fn "fetch")
arguments: (arguments
(identifier) @url_arg
(#match? @url_arg "(Url|BaseUrl|WebhookUrl|ApiUrl|NotifyUrl)$")
)
) @risky_fetch
; SA-SKL-SSRF34 Query 2 — Detect response body stored to DB after fetch of configurable URL
; Matches await response.text() / response.json() result used in a db.*.create() call
(await_expression
(call_expression
function: (member_expression
object: (identifier) @resp (#eq? @resp "response")
property: (property_identifier) @method
(#match? @method "^(text|json|arrayBuffer)$")
)
)
) @response_body
(call_expression
function: (member_expression
object: (member_expression object: (identifier) @db (#eq? @db "db"))
property: (property_identifier) @action
(#match? @action "^(create|insert|save|update)$")
)
) @db_write
Summary
| ID | Severity | Endpoint / Function | Root Cause | Fix |
|---|---|---|---|---|
| SSRF34-001 | Critical | fetchGitHubUser() — githubApiUrl |
User-supplied GitHub Enterprise API URL fetched without hostname allowlist or private-IP block; error response body persisted to audit log | Allowlist of GitHub/GHE hostnames; DNS-based private-IP validation; strip response bodies from audit log entries |
| SSRF34-002 | High | createJiraTicket() — jiraBaseUrl |
User-supplied Jira base URL fetched without host validation; error response body (Prometheus metrics) stored as ticket description | DNS-verified hostname stored at config time; DNS rebinding re-check at request time; Content-Type + schema assertion; never store error response bodies |
| SSRF34-003 | High | testSlackWebhook() — slackWebhookUrl |
User-supplied Slack webhook URL POST'd without host validation; redirect: follow allows redirect chain; test payload sent to InfluxDB writes metrics |
Allowlist hooks.slack.com only; redirect: error; fixed constant payload; return success boolean only |
| SSRF34-004 | High | sendNotification() — notifyUrl |
User-supplied notification URL GET-fetched without private-IP block; full response body from internal Kibana stored in DB | DNS private-IP block; redirect: error; store only delivery boolean — never response body |
Run a free SkillAudit scan on any public MCP skill repository at skillaudit.dev. Reports include SSRF checks alongside code injection, CORS misconfiguration, privilege escalation, and 40+ other categories.