Summary
Chainlit deployments with MCP enabled may expose an unauthenticated endpoint that accepts attacker-controlled destination URLs and request headers. This can cause the server to make outbound requests to internal services, cloud metadata endpoints, or external systems, including state-changing requests made with supplied credentials.
Affected context
The vulnerability occurs in Chainlit deployments where MCP is enabled through the application configuration and the MCP endpoint is reachable without authentication. The risk is highest when the server can access private network resources, cloud metadata services, or trusted APIs, and when outbound traffic is not restricted by network policy.
Exploit preconditions
- Attack surface: The unauthenticated POST
/mcpendpoint - Required access: Network access to the exposed Chainlit service; valid application authentication is not required for the affected endpoint
- Trigger point: Processing an MCP connection request containing a user-controlled URL and optional headers
- Why exploitation is possible: The server forwards the supplied destination and headers to outbound MCP client transports without sufficient scheme validation, private-address filtering, or destination allowlisting
Why this happens
The underlying issue is server-side request forgery caused by treating client-supplied connection targets as trusted outbound destinations. The MCP connection handler passes attacker-controlled URLs and headers to network client functions without enforcing safe schemes, blocking private or link-local addresses, or restricting destinations to an approved set. This behavior maps to CWE-918: Server-Side Request Forgery, because the server can be induced to make requests on behalf of an external user.
Potential impact
- An attacker may discover internal services and scan reachable ports
- The server could access cloud instance metadata or other restricted endpoints
- Attacker-controlled headers may enable unauthorized requests to trusted services
- State-changing actions could be performed against internal or external systems
- Sensitive response effects or service behavior may be inferred even when response content is not returned
- Network segmentation and trust boundaries could be weakened
General mitigation guidance
Mitigation generally focuses on reducing trust in client-supplied destinations and limiting the server's outbound network capabilities.
Common defensive patterns include:
- Require authentication and authorization for MCP connection endpoints
- Permit outbound connections only to explicitly approved destinations
- Allow only required URL schemes and reject ambiguous or unsafe schemes
- Block loopback, link-local, private, multicast, and reserved address ranges after DNS resolution
- Restrict or remove user-controlled forwarding of Authorization, Cookie, and similar sensitive headers
- Apply egress firewall rules and network policies around application workloads
- Run the service with least-privilege network and cloud permissions
- Use separate credentials and trust boundaries for outbound integrations
How teams detect issues like this
Detection approaches can include:
- Static analysis for network client calls that consume request parameters without destination validation
- Code review checks for URL sinks accepting user-controlled values
- Rules identifying outbound forwarding of Authorization, Cookie, or other sensitive headers
- API security tests for unauthenticated endpoints that initiate server-side connections
- Runtime monitoring of outbound requests to private, link-local, metadata, or unexpected external addresses
- Network policy alerts for unusual egress destinations, ports, or request methods
- Automated security review tools that flag SSRF-prone URL handling and missing allowlists

