/

CVE-2026-31943

Severity:

HIGH RISK

(8.5)

Server-Side Request Forgery (SSRF) in LibreChat API

CVE-2026-31943

Modified

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Unauthorized access to internal network and cloud metadata via SSRF

Severity:

HIGH RISK

(8.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/danny-avila/LibreChat/security/advisories/GHSA-w5r7-4f94-vp4c

Frequently asked

questions

Exploitability is high whenever authenticated users can influence URLs that the server fetches, and when the server has network-level access to internal resources or metadata endpoints. In such configurations, a motivated attacker can often identify encodings that bypass the IP checks and gain access to sensitive internal services.

No. The description indicates that any authenticated user is sufficient, provided they can trigger server-side HTTP requests with user-controlled destinations. No elevated in-application role is required beyond access to the relevant feature.

Avoid relying solely on ad-hoc IP classification helpers. Instead, canonicalize resolved addresses, use well-tested libraries for private/reserved range detection that cover IPv4, IPv6, and mapped variants, and combine this with strict allowlists for where the server is permitted to connect.

Design server-side integrations with a "default deny" mindset: restrict outbound connections to specific domains or networks, enforce robust URL and IP canonicalization before validation, and apply network-level egress controls to block access to metadata and sensitive internal ranges. Regular security reviews and automated tests that include edge-case address representations help catch regressions early.

Find out what's already
exploitable in your codebase.