Summary
OpenClaw's fetchWithSsrFGuard function improperly forwards custom authorization headers (such as X-Api-Key and Private-Token) across cross-origin redirects.
When a request is redirected to a different origin, these sensitive headers may be sent to an attacker-controlled endpoint, exposing secrets intended only for the original destination.
Affected context
This vulnerability occurs in OpenClaw deployments that:
- Use fetchWithSsrFGuard to issue HTTP requests that include sensitive custom headers (e.g., X-Api-Key, Private-Token, or similar secrets)
- Allow the initial target endpoint to respond with HTTP redirects (3xx) to arbitrary locations
- Do not constrain or sanitize the forwarding of authorization-related headers when the redirect crosses origin boundaries
The issue is most critical when the redirected location can be influenced or controlled by an attacker, enabling them to receive headers that should remain confined to the original trusted service.
Exploit preconditions
- Attack surface: Server-side or backend HTTP requests made through fetchWithSsrFGuard
- Required access: Ability to:
- Control or influence the redirect target of an HTTP 3xx response, or
- Operate a service that OpenClaw will request and follow redirects from
- Trigger point: A fetchWithSsrFGuard call that:
- Sends sensitive headers to an initial origin, and
- Follows an HTTP redirect to a different origin while still forwarding those headers
- Why exploitation is possible: The implementation does not enforce origin checks or header stripping on cross-origin redirects, so secrets attached to the original request are automatically forwarded to the new, potentially malicious origin.
Why this happens
The underlying bug is a failure to properly protect sensitive credentials during HTTP redirection.
fetchWithSsrFGuard attaches authorization-like headers to outgoing requests and continues to send them on all subsequent redirect hops, regardless of changes in origin.
This maps to CWE-522: Insufficiently Protected Credentials, where sensitive tokens are handled without appropriate contextual safeguards such as origin scoping, header filtering, or redirect-aware policies.
In abstract terms, the component incorrectly assumes that redirects are trustworthy and that headers suitable for one origin remain safe when the request transparently moves to another, breaking the trust boundary around those credentials.
Potential impact
- Exposure of API keys, private tokens, or other authorization headers to attacker-controlled domains
- Unauthorized access to protected APIs using leaked credentials
- Account takeover or impersonation of backend services relying on the compromised tokens
- Lateral movement into internal systems that trust the leaked credentials
- Data exfiltration from services accessed with the stolen tokens
General mitigation guidance
Effective mitigation focuses on constraining where sensitive headers are sent and how redirects are handled:
- Limit authorization-like headers to a narrowly defined set of trusted origins; avoid attaching them to generic or user-influenced URLs.
- Strip or withhold sensitive headers on cross-origin redirects, only allowing them to propagate when the redirect target matches the original origin or a pre-approved list.
- Introduce redirect policies that distinguish between same-origin and cross-origin redirects, failing closed for untrusted locations.
- Centralize credential handling so that tokens are added as close as possible to the final, validated destination rather than at the start of a redirect chain.
- Apply the principle of least privilege when issuing and scoping API keys and tokens, reducing their power if they are ever exposed.
How teams detect issues like this
Detection efforts can focus on both code behavior and runtime signals:
- Static analysis and code review:
- Search for wrapper functions (like fetchWithSsrFGuard) that attach sensitive headers and automatically follow redirects.
- Flag logic that forwards authorization-related headers without validating the redirect target's origin.
- Review HTTP client configurations for unrestricted redirect-following combined with credentialed requests.
- Runtime and policy enforcement:
- Inspect outbound traffic logs to identify sensitive headers being sent to unexpected or untrusted domains.
- Use HTTP proxies or gateways to enforce policies that block or scrub authorization headers on cross-origin redirects.
- Integrate automated security review tools that highlight unsafe redirect + credential patterns as part of CI/CD pipelines.

