Summary
LLaMA-Factory contains a server-side request forgery vulnerability in its OpenAI-compatible API handler for multimodal media URLs. An unauthenticated attacker may bypass URL validation through redirects or DNS rebinding, potentially causing the server to request internal services or cloud metadata endpoints.
Affected context
The vulnerability occurs in deployments exposing LLaMA-Factory's OpenAI-compatible multimodal API. It becomes risky when user-controlled media URLs are fetched by the server, the initial URL is validated separately from the eventual connection, and outbound requests can reach private addresses, internal services, or cloud metadata endpoints.
Exploit preconditions
- Attack surface: OpenAI-compatible API endpoint that accepts remote multimodal media URLs
- Required access: No authentication may be required when the affected API is publicly reachable
- Trigger point: Server-side retrieval of an attacker-influenced media URL
- Why exploitation is possible: URL validation is performed before request processing, while redirects and subsequent DNS resolution can lead the request to a different, unvalidated destination
Why this happens
The underlying bug is a mismatch between URL validation and network request behavior. The application checks the initial destination with an SSRF guard, but the HTTP client may follow redirects or resolve the hostname again without applying equivalent validation to each resulting connection. This maps to CWE-918: Server-Side Request Forgery, where attacker-controlled input influences server-side requests to unintended resources.
Potential impact
- Access to internal administrative or service endpoints
- Retrieval of cloud instance metadata or temporary credentials
- Exposure of sensitive response data to the attacker
- Internal network reconnaissance
- Potential follow-on compromise if reachable services trust the affected host
General mitigation guidance
Mitigation generally focuses on enforcing destination controls throughout the complete request lifecycle.
Common defensive patterns include:
- Disable automatic redirect following for user-controlled media retrieval, or validate every redirect destination
- Resolve hostnames and validate the resulting addresses before each connection
- Reject private, loopback, link-local, reserved, and other non-public destination ranges
- Prefer explicit outbound allowlists for required media hosts
- Restrict server egress through network policies, proxies, and firewall controls
- Apply authentication, authorization, and rate limits to media-fetching API paths
- Run the service with minimal network and cloud-instance permissions
These controls reduce reliance on a single URL check and limit impact if validation is bypassed.
How teams detect issues like this
Detection approaches commonly include:
- Static analysis for URL validation followed by HTTP requests that permit redirects
- Code review checks comparing validation behavior with the HTTP client's redirect and DNS-resolution behavior
- Tests covering redirects, hostname changes, DNS rebinding conditions, and private-address resolution
- Network monitoring for application-originated requests to loopback, private, link-local, and metadata service ranges
- Egress policies that alert on or block unexpected internal destinations
- Automated security review tools that identify server-side requests built from user-controlled URLs

