Summary
curl_cffi, a Python binding for curl, allowed attacker-controlled URLs to trigger server-side requests to internal network resources by automatically following redirects without restricting internal IP ranges.
When combined with its TLS impersonation feature, these redirected requests could appear as legitimate browser traffic, potentially bypassing network-based protections and exposing sensitive internal services such as cloud metadata endpoints.
Affected context
This vulnerability affects applications that:
- Use curl_cffi as an HTTP client library prior to version 0.15.0
- Allow user-supplied or otherwise untrusted URLs to be fetched
- Rely on curl_cffi's default behavior for redirect handling
- Operate in environments where the runtime has network visibility into internal services (e.g., VPC-only services, cloud metadata endpoints, internal APIs)
The issue is more pronounced in architectures where outbound egress controls trust TLS fingerprints or browser impersonation to distinguish user traffic from automated calls.
Exploit preconditions
- Attack surface: Any HTTP(S) endpoint in the application that fetches external URLs via curl_cffi (e.g., URL preview APIs, webhooks, proxy endpoints, health checks configured with external URLs).
- Required access: Ability to supply or influence the target URL, typically via HTTP parameters, configuration fields, or indirectly through stored references.
- Trigger point: A request made by the application using curl_cffi to an attacker-controlled or attacker-influenced URL that returns a redirect (3xx) to an internal or otherwise protected endpoint.
- Why exploitation is possible:
- curl_cffi followed redirects automatically via libcurl.
- No filtering or blocking of redirects to internal IP ranges or well-known metadata hostnames.
- TLS impersonation made the outbound connection look like traffic from a standard browser, potentially bypassing naive network filters and egress controls.
Why this happens
The root cause maps to CWE-918: Server-Side Request Forgery (SSRF), where a server component issues HTTP requests based on untrusted input without appropriate destination validation.
curl_cffi exposed libcurl's powerful redirect and impersonation capabilities but did not enforce safeguards around:
- Restricting follow-up requests to internal/private IP ranges
- Denying redirects to special-purpose endpoints like cloud metadata services
- Providing safe-by-default redirect policies when user-controlled URLs are involved
As a result, an attacker could influence the library's behavior so that it acted as a network proxy into otherwise non-routable or protected resources, leveraging the server's privileged network position.
Potential impact
- Access to cloud provider metadata services, which could include:
- Temporary credentials or API tokens
- Instance identity documents
- Sensitive configuration values
- Discovery and probing of internal network services (port scanning by redirect chaining).
- Unauthorized access to internal HTTP APIs that are not exposed externally.
- Bypassing of network-layer defenses that depend on distinguishing browser traffic from automated client traffic.
- Use of the server as a pivot point for further lateral movement within the internal network.
General mitigation guidance
Effective mitigation focuses on constraining where server-initiated HTTP requests may go and reducing trust in user-controlled URLs:
- Prefer HTTP client configurations that:
- Disable automatic redirect following by default, especially when URLs can be influenced by users.
- Enforce strict allowlists of permitted domains or URL patterns for outbound requests.
- Block or closely scrutinize requests to internal/private IP ranges (e.g., RFC1918 addresses, link-local ranges, 169.254.169.254, internal hostnames).
- Introduce a dedicated outbound request policy layer that:
- Performs DNS resolution and IP classification before connecting.
- Rejects requests to metadata endpoints and known sensitive infrastructure IPs.
- Logs and rate-limits requests to suspicious destinations.
- Design application features to:
- Avoid fetching arbitrary URLs directly; use curated, server-side validated targets instead.
- Treat any URL received from clients as untrusted, subject to validation, normalization, and policy enforcement.
- Run services with the principle of least privilege:
- Restrict network egress where feasible so that application instances cannot directly reach sensitive internal services and metadata endpoints.
- Separate roles so that components that must reach metadata or admin APIs do not process untrusted URL input.
How teams detect issues like this
Detection centers on identifying risky SSRF patterns and monitoring unusual outbound request behavior:
- Static analysis and code review:
- Flag use of curl_cffi (or similar HTTP clients) where the URL or redirect behavior is influenced by user input.
- Look for calls that enable automatic redirects without validating redirect destinations.
- Highlight code that uses TLS impersonation or browser-mimicking behaviors for outbound requests.
- Configuration and policy checks:
- Enforce coding guidelines that require allowlisted destinations for server-initiated HTTP calls.
- Require explicit justification and review for enabling redirect following and impersonation features.
- Runtime monitoring and logging:
- Log outbound connections, including final resolved IPs and redirect chains.
- Alert on traffic from application servers to:
- Cloud metadata IPs (e.g., 169.254.169.254, metadata.google.internal).
- Internal/private IP address ranges that are not part of normal operational patterns.
- Use network-level tools (e.g., egress firewalls, proxy logs) to identify SSRF-like patterns such as many different internal targets being reached through a single external URL endpoint.

