Summary
A Server-Side Request Forgery (SSRF) flaw in the /api/files/export-content endpoint of Lollms allows user-supplied URLs to be fetched by the server without proper validation.
In deployments where the Lollms backend can reach internal or cloud metadata networks, an attacker may leverage this behavior to access internal services, perform port scanning, exfiltrate metadata, and in some environments pivot toward remote code execution.
Affected context
The issue arises in Lollms instances that expose the /api/files/export-content API and allow users to provide arbitrary URLs for content export.
It is most impactful when:
- The backend host has network connectivity to internal services (e.g., databases, admin panels, service meshes), and/or
- The environment runs in cloud infrastructure where metadata endpoints are reachable from the instance,
- Outbound egress traffic from the backend is unrestricted or only lightly filtered.
Under these conditions, the backend becomes an involuntary proxy into otherwise non-public network locations.
Exploit preconditions
- Attack surface: HTTP API endpoint
/api/files/export-contentexposed to users or integrated services. - Required access: Ability to submit requests to this endpoint with attacker-controlled URL parameters (typically unauthenticated or authenticated user, depending on deployment).
- Trigger point: The
_download_image_to_temp()function inbackend/routers/files.pyis invoked with the supplied URL and issues outbound HTTP requests on behalf of the server. - Why exploitation is possible: The function does not sufficiently validate or restrict destination URLs (e.g., scheme, host, IP range, or metadata paths), allowing attackers to direct the server to contact arbitrary internal or external network locations.
Why this happens
This vulnerability stems from treating user-controlled URLs as trusted destinations for server-side HTTP requests.
The _download_image_to_temp() helper in backend/routers/files.py acts as a generic HTTP client without enforcing network-level or application-level egress restrictions.
No filtering is applied to prevent access to loopback, link-local, or private IP ranges, nor to known sensitive paths such as cloud provider metadata services.
This aligns with CWE-918: Server-Side Request Forgery (SSRF), where an application fetches remote resources based on untrusted input, unintentionally exposing its own network position, privileges, and trust boundaries.
Potential impact
- Access to internal HTTP(S) services that are not directly exposed to the internet (e.g., admin panels, internal APIs, dashboards).
- Interaction with cloud metadata endpoints, which may expose credentials, access tokens, and instance configuration.
- Internal network mapping and port scanning by observing response behavior, errors, and timing.
- Potential exploitation of internal services via the SSRF channel, which can in turn lead to remote code execution where vulnerable services are reachable.
- Exfiltration of sensitive configuration data or service responses accessible only from the backend network.
General mitigation guidance
Effective mitigation focuses on strictly controlling server-initiated outbound requests and reducing trust in user-supplied URLs:
- Introduce a positive-allowlist for outbound destinations, limiting requests to a small set of known-safe domains or hosts.
- Validate URL schemes and reject non-HTTP/HTTPS schemes, as well as malformed or encoded URLs that might bypass filters.
- Implement network-level egress controls (firewall rules, security groups) to prevent access to internal address ranges and metadata endpoints from the application host.
- Normalize and parse URLs server-side, then resolve and verify the final destination IP against allowed ranges before making any request.
- Where possible, decouple file retrieval from arbitrary URLs by using indirect references (e.g., object storage identifiers) instead of raw user URLs.
- Apply least-privilege principles for the runtime environment so that, even if SSRF occurs, the backend has minimal access to internal assets and cloud privileges.
How teams detect issues like this
Organizations can use a mix of code-centric and operational approaches to detect SSRF risks:
- Static analysis: Search for HTTP client usage (e.g.,
requests,httpx,urllib, or framework-specific clients) where the URL is derived from request parameters or other user-controlled input without prior validation or restriction. - Code review: Flag patterns where helper functions like
_download_image_to_temp()accept arbitrary URLs and are reachable from public endpoints, especially when there is no allowlist, scheme filtering, or IP-range checks. - Security testing: Perform targeted SSRF tests against exposed endpoints by supplying URLs pointing to:
- Reserved IP ranges (127.0.0.0/8, 10.0.0.0/8, 169.254.169.254, etc.)
- Non-routable or invalid domains, observing response differences, timeouts, or error messages.
- Runtime monitoring: Use network telemetry and logging to identify unusual outgoing requests from application nodes, such as connections to internal subnets or metadata services that should not be accessed.
- Automated SAST and DAST tools can be configured to specifically highlight SSRF patterns in URL-handling functions and API routes.

