Summary
The lmdeploy OpenAI-compatible API server contains a server-side request forgery flaw that lets attackers pivot outbound HTTP requests toward internal services and cloud metadata endpoints.
By abusing image_url handling and unvalidated HTTP redirects, unauthenticated attackers can coerce the server into fetching sensitive internal resources that are not directly exposed.
Affected context
This vulnerability appears when lmdeploy is deployed with its OpenAI-compatible API server exposed to untrusted clients and configured to fetch remote image URLs on behalf of users.
Risk increases in environments where:
- The server can reach internal network segments or instance metadata endpoints
- Outbound HTTP requests are allowed without strict egress filtering
- URL safety checks are performed only on the initial request, not on redirects
Exploit preconditions
- Attack surface: Publicly exposed chat completions endpoint that accepts image_url parameters
- Required access: Network reachability to the API server; no authentication is required
- Trigger point: Submission of a crafted POST request where image_url points to an attacker-controlled host that responds with an HTTP 302/3xx redirect
- Why exploitation is possible: The server follows redirects from the attacker-controlled URL to internal addresses (e.g., loopback, metadata endpoints) without re-applying URL validation or safety checks on each redirect hop
Why this happens
The underlying bug aligns with CWE-918: Server-Side Request Forgery.
The application performs outgoing HTTP requests based on user-provided URLs, performing an initial safety validation but then automatically following HTTP redirects without re-validating the redirected target.
This pattern effectively turns the server into an HTTP proxy into its own network environment, allowing untrusted input (image_url plus redirect behavior) to control where the server connects internally.
The absence of strict network boundary checks and per-hop URL validation enables access to resources that should be unreachable from external clients.
Potential impact
- Unauthorized access to cloud instance metadata services, which may yield credentials or sensitive configuration
- Enumeration and probing of internal HTTP services and management endpoints
- Potential credential theft or token exfiltration from metadata or internal APIs
- Use of the server as a stepping stone for further attacks against internal infrastructure
- Exposure of internal service responses and configuration details to external attackers
General mitigation guidance
Mitigation typically focuses on reducing trust in user-supplied URLs and constraining the server's network reach.
Effective patterns include:
- Enforcing strict allowlists or blocklists for outbound HTTP destinations, explicitly excluding loopback, RFC1918 ranges, link-local and metadata service IPs/hostnames
- Re-validating every redirect target during HTTP request handling, applying the same safety guard to each hop or disallowing redirects entirely for user-controlled URLs
- Decoupling image or resource fetching from the core API by using dedicated, locked-down fetcher services with narrow egress policies
- Applying least-privilege networking: limit outbound access to only required external domains and block internal address ranges at the network layer
- Avoiding implicit proxy behavior where server-side requests mirror arbitrary client-supplied URLs
How teams detect issues like this
Detection can combine code-level and operational techniques:
- Static analysis or manual code review to identify patterns where user-supplied URLs are fetched server-side, especially when redirect following is enabled without per-hop validation
- Review of HTTP client configuration for permissive redirect handling and absence of IP/hostname filtering logic
- Logging and monitoring of outbound HTTP requests from the API server, alerting on connections to internal IP ranges or known metadata endpoints
- Policy-based checks in CI/CD pipelines that flag new or modified code performing server-side URL fetches without explicit SSRF safeguards
- Periodic penetration testing and SSRF-focused security assessments targeting image_url and similar parameters that trigger remote fetches

