Skip to content

MCP client does not validate server URLs against SSRF #662

Description

@Carlys17

Summary

MCP SSE and Streamable HTTP transports (src/agentos/mcp/sse.py, src/agentos/mcp/streamable_http.py) connect to MCPServerConfig.url via httpx with no SSRF validation. Every other URL-fetching path (web_fetch, http_request, skill-hub) calls validate_http_url_for_fetch() before connecting — the MCP transport skips this entirely.

Impact

Cloud metadata endpoints (169.254.169.254), private ranges, and unsupported schemes are reachable through MCP server config. An attacker who controls or injects the MCP server URL can exfiltrate instance credentials or redirect agent traffic to internal hosts.

Suggested fix

Call validate_http_url_for_fetch(self.config.url) in both MCPSSEClient.connect() and StreamableHttpTransport.connect() before creating the httpx client. This is the same guard used by web_fetch and http_request.

Suggested labels: type: security, type: bug, area: mcp

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Medium priority: important but has a workaround or limited impactstatus: readyScoped and ready for implementationtype: bugSomething isn't workingtype: securityPotential vulnerability or security-sensitive work; follow SECURITY.md

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions