Summary
Portkey AI Gateway contains a server-side request forgery vulnerability in the /v1/proxy/* route because requests can bypass expected validation.
An attacker may direct the gateway to internal services and cause forwarded Authorization headers to expose credentials, including provider API keys, when the route is reachable and the attacker can control the custom host value.
Affected context
The vulnerability occurs in deployments using the Portkey AI Gateway proxy route where the request validation middleware is absent or not applied. Risk is higher when the gateway can reach internal network services, accepts attacker-controlled host-routing headers, and forwards sensitive authorization headers to the selected destination.
Exploit preconditions
- Attack surface: The externally reachable
/v1/proxy/*gateway route - Required access: Ability to submit requests to the proxy endpoint; authentication requirements depend on deployment configuration
- Trigger point: Processing of a request containing an attacker-controlled
x-portkey-custom-hostheader - Why exploitation is possible: The route may forward requests to internal addresses without sufficient destination validation or controls on authorization-header propagation
Why this happens
The underlying flaw is server-side request forgery caused by incomplete request validation on a proxy route. The gateway trusts a client-controlled host-routing value and uses it to determine the upstream destination without reliably restricting private, loopback, link-local, or otherwise unauthorized network targets. Forwarding Authorization headers across that trust boundary can also expose credentials to unintended services, mapping the behavior to CWE-918: Server-Side Request Forgery.
Potential impact
- An attacker may access internal HTTP services that are not externally reachable.
- Internal metadata or administrative endpoints could be queried.
- Forwarded authorization headers could expose provider API keys or other credentials.
- The gateway could be used to probe internal network topology.
- Compromised credentials could enable unauthorized access to downstream services.
General mitigation guidance
Mitigation typically focuses on enforcing destination validation and reducing trust in client-controlled routing headers.
Common defensive patterns include:
- Applying request validation middleware consistently to every proxy route.
- Allowlisting approved upstream hosts and schemes instead of accepting arbitrary destinations.
- Blocking loopback, private, link-local, metadata-service, and other restricted address ranges after DNS resolution.
- Revalidating destinations across redirects and preventing unsafe protocol changes.
- Stripping or selectively reconstructing authorization headers rather than forwarding them by default.
- Running the gateway with network egress restrictions and least-privilege access to internal services.
- Keeping provider credentials outside request-controlled paths and limiting their scope.
How teams detect issues like this
Organizations can detect SSRF risks through:
- Static analysis rules for HTTP clients whose destinations derive from request headers or parameters.
- Code review checks for missing validation middleware on proxy and redirect routes.
- Tests covering private, loopback, link-local, metadata, alternate numeric, and DNS-resolving addresses.
- Network monitoring for gateway connections to internal address ranges or unexpected destinations.
- Policy enforcement requiring outbound allowlists and explicit authorization-header handling.
- Automated security review tools that identify user-controlled URL construction and proxy behavior.

