Summary
A server-side request forgery (SSRF) vulnerability in the LLM Models API of mcp-chat-studio up to version 1.5.0 allows an attacker to control outbound HTTP requests via the req.query.base_url parameter.
When an attacker can supply arbitrary URLs to this parameter, they may coerce the server into connecting to internal or protected endpoints that are not directly accessible from the internet.
Affected context
The vulnerability exists in the server/routes/llm.js route handler that implements the LLM Models API.
It affects deployments where:
- Client-supplied query parameters, specifically
req.query.base_url, are used to construct outbound requests to LLM endpoints or other HTTP services. - There is no strict allowlist or validation of the destination host, scheme, or port.
- The application server has network visibility into internal services, metadata endpoints, or other resources not exposed externally.
Exploit preconditions
- Attack surface: Public or exposed HTTP endpoint for the LLM Models API, reachable by remote clients.
- Required access: Ability to send requests to the affected route with a controllable
base_urlquery parameter (typically unauthenticated or low-privileged web access). - Trigger point: The handler in
server/routes/llm.jsusesreq.query.base_urlto construct an outbound HTTP request without robust validation or restriction. - Why exploitation is possible: The server trusts the
base_urlvalue and uses it directly (or with insufficient checks) when making server-side requests, enabling the attacker to redirect those requests to arbitrary URLs under their control or to internal network locations.
Why this happens
This issue is an instance of CWE-918: Server-Side Request Forgery (SSRF).
The route handling logic for the LLM Models API appears to treat a user-controlled parameter (req.query.base_url) as a trusted endpoint definition, embedding it into outbound HTTP calls.
By failing to constrain which hosts, protocols, or paths can be targeted, the application exposes its own network connectivity as an attack primitive.
In abstract terms, untrusted input is used to define remote resource locations for server-initiated requests, effectively delegating network routing decisions to the attacker.
Potential impact
- Access to internal HTTP services that are not exposed to the public internet (e.g., internal APIs, admin panels, or microservices).
- Interaction with cloud provider metadata endpoints, which may reveal sensitive instance credentials or configuration.
- Enumeration of internal network structure (open ports, available services, behavior of internal endpoints).
- Use of the application server as a proxy to bypass IP-based access controls or firewall rules.
- Potential chaining with other vulnerabilities on reachable internal systems (e.g., exploiting admin interfaces or weakly protected endpoints).
General mitigation guidance
Effective mitigation for SSRF in this context focuses on constraining outbound connections and reducing trust in user-controlled URLs:
- Prefer fixed, configuration-driven endpoints for LLM providers instead of accepting arbitrary base URLs from client input.
- If dynamic endpoints are required, enforce a strict allowlist of permitted hosts and, where possible, specific paths and ports.
- Validate
base_urlinputs rigorously: - Restrict protocols to
https(or a small, expected set). - Block private, loopback, link-local, and link-local metadata address ranges by default.
- Normalize and re-parse URLs after resolution to ensure no DNS rebinding or scheme confusion.
- Where feasible, route outbound traffic through a network egress proxy with filtering rules that forbid access to internal or metadata networks.
- Apply least-privilege network policies (e.g., firewall rules, Kubernetes NetworkPolicies, security groups) so the application can only reach the specific external LLM endpoints it needs.
How teams detect issues like this
Detection of SSRF patterns and potential exploitation can be approached at several layers:
- Static analysis/code scanning:
- Identify places where user input (e.g.,
req.query.base_url, headers, or body fields) flows into HTTP client calls, URL constructors, or request libraries. - Flag dynamic URL composition that is not guarded by allowlists or robust validation.
- Code review practices:
- During review of route handlers like
server/routes/llm.js, verify that any user-influenced URL parameters are tightly controlled. - Look for helper functions that build outbound requests and ensure they centralize validation and host restrictions.
- Runtime and observability:
- Monitor outbound traffic from the application for unusual destinations, such as private IP ranges,
169.254.169.254, or internal domains that should not be contacted. - Use application logs to track the effective URLs being requested by the LLM Models API and alert on anomalies or patterns indicative of scanning.
- Security testing:
- Include SSRF-focused test cases in API security testing, fuzzing
base_url(and similar parameters) with internal and metadata targets to validate defenses.

