Summary
LibreChat's server-side request protections can be bypassed when IPv4-mapped IPv6 addresses are provided in their hex-normalized form, causing the isPrivateIP() helper to misclassify internal destinations as external.
Under these conditions, an authenticated user may coerce the server into issuing HTTP requests to internal network resources, including loopback, RFC1918 ranges, and cloud metadata services.
Affected context
This vulnerability appears in LibreChat deployments where:
- The backend exposes functionality that makes outbound HTTP(S) requests on behalf of users
- Destination URLs or hosts are derived from user-controlled input
- The
isPrivateIP()helper is used to block internal or private IP ranges - IPv4-mapped IPv6 addresses in hex-normalized form are not correctly recognized as private
In such environments, the trust boundary between the external client and the internal network is enforced only through this IP classification logic, making its correctness critical.
Exploit preconditions
- Attack surface: Server-side features that fetch or proxy arbitrary or partially user-influenced URLs (e.g., integrations, webhooks, document fetchers, or connector endpoints).
- Required access: Any authenticated LibreChat user account that can supply a URL or host to the vulnerable API path.
- Trigger point: Submission of a crafted URL that resolves to an internal IP (loopback, RFC1918, or cloud metadata) encoded as an IPv4-mapped IPv6 in hex-normalized form.
- Why exploitation is possible: The
isPrivateIP()function applies insufficient validation and does not correctly interpret these IPv6 representations as private or internal, causing the request to pass SSRF checks and be performed by the server.
Why this happens
The root cause lies in incomplete address classification logic within isPrivateIP() in packages/api/src/auth/domain.ts.
The function is intended to detect and block private, loopback, and special-purpose IP ranges, but its implementation assumes a limited set of string formats and direct IPv4 or straightforward IPv6 representations.
IPv4-mapped IPv6 addresses in hex-normalized form fall outside of these assumptions, leading the function to treat internal endpoints as if they were safe external addresses.
This aligns with CWE-918: Server-Side Request Forgery (SSRF), where insufficient validation of server-initiated requests allows attackers to pivot into internal networks through the application's own HTTP client.
Potential impact
- Access to cloud instance metadata endpoints (e.g., AWS
169.254.169.254) which may expose credentials, tokens, or configuration data - Discovery and interaction with internal-only HTTP services, including admin panels, internal APIs, and management endpoints
- Use of the server as a blind port scanner against internal network ranges
- Bypassing network-layer controls such as firewalls or IP allowlists that trust the application server's origin
- Potential privilege escalation if metadata or internal services provide secrets or higher-privileged access tokens
- Lateral movement opportunities inside the hosting environment through exposed internal control planes
General mitigation guidance
Effective mitigation focuses on hardening server-side HTTP request patterns and making internal network access opt-in and explicit:
- Prefer strict allowlists of known-good destinations for server-initiated HTTP requests, rather than relying solely on blocklists or IP classification.
- Normalize and canonicalize all resolved addresses (including IPv4-mapped IPv6 and different textual forms) before performing trust decisions.
- Use mature, security-reviewed libraries or system facilities for private/reserved IP detection instead of custom ad-hoc logic.
- Apply layered defenses: in addition to application-level checks, consider network-level controls (e.g., egress filtering, VPC security groups) that prevent the application server from reaching metadata endpoints or sensitive internal ranges by default.
- Isolate outbound HTTP clients used for untrusted destinations in separate network segments with limited reach.
- Design features so that server-side requests on behalf of users do not need broad arbitrary URL support; where possible, constrain to specific domains or well-known APIs.
How teams detect issues like this
Detection can combine code-level review with behavioral monitoring:
- Static analysis and code review:
- Flag custom IP parsing and classification functions, especially those used in SSRF defenses, for detailed security review.
- Look for logic that assumes specific string formats for IP addresses or neglects IPv4-mapped IPv6 and alternative textual forms.
- Review all call sites that pass user-derived URLs or hosts into HTTP clients and ensure they apply canonicalization and robust SSRF checks.
- Dynamic and operational monitoring:
- Monitor outbound requests from the application to internal IP ranges, link-local ranges (such as
169.254.169.254), and loopback addresses. - Configure logging for server-initiated HTTP calls that includes the final resolved IP and not just the original hostname.
- Security testing:
- Incorporate SSRF test cases involving IPv6, IPv4-mapped IPv6, and unusual encodings into security testing and CI pipelines.
- Utilize automated security scanning tools that specifically probe for SSRF and IP-parsing edge cases.

