Summary
Headroom versions before 0.35.0 do not validate the Origin header on incoming WebSocket connections before forwarding requests to an upstream large language model service. A malicious WebSocket client may therefore submit unauthorized LLM requests when it can reach the Headroom proxy and the proxy exposes an OpenAI API key through its environment.
Affected context
The vulnerability occurs in deployments where the Headroom WebSocket server is reachable by untrusted browser-based or headless-browser clients, forwards requests to an upstream LLM provider, and relies on an environment-held API key without an additional client authentication boundary. The risk is higher when cross-origin WebSocket connections are permitted or when network access to the proxy is broader than intended.
Exploit preconditions
- Attack surface: Headroom's WebSocket endpoint
- Required access: Network reachability to the Headroom proxy; valid client authentication may not be required
- Trigger point: Establishment of a WebSocket connection followed by forwarding an LLM request
- Why exploitation is possible: The server does not adequately validate the client's Origin or otherwise establish that the request came from an authorized application before using its upstream API credentials
Why this happens
The underlying bug is an authentication and origin-trust failure. The WebSocket server accepts client connections without reliably validating the Origin header or applying an equivalent authorization control, then forwards requests using credentials held by the server. This maps primarily to CWE-287: Improper Authentication and is related to CWE-1385: Missing Origin Validation in WebSockets, because an untrusted client can be treated as an authorized browser context.
Potential impact
- Attackers may submit arbitrary requests to the upstream LLM service
- The exposed API key may incur unauthorized usage charges or quota consumption
- Confidential prompts, responses, or proxy-accessible data could be disclosed
- Attackers could abuse the service for automated or harmful content generation
- The upstream provider account or connected application may be subject to rate limits or suspension
General mitigation guidance
Mitigation generally focuses on making WebSocket authorization explicit rather than relying on browser behavior or the Origin header alone.
Common defensive patterns include:
- Enforcing an allowlist of trusted origins before accepting or forwarding WebSocket requests
- Requiring authenticated, authorized client sessions with appropriate access scopes
- Separating browser-facing proxy access from server-side upstream API credentials
- Restricting network exposure of the WebSocket endpoint to trusted applications or networks
- Applying rate limits, usage quotas, request-size limits, and monitoring around LLM forwarding
- Storing upstream credentials in protected secret-management systems and minimizing their privileges
- Rejecting requests by default when origin or authorization information is absent, malformed, or ambiguous
How teams detect issues like this
Detection approaches may include:
- Static analysis and code review checks for WebSocket handlers that accept connections without origin or authorization validation
- Reviewing whether upstream API credentials are used for requests from unauthenticated client sessions
- Testing cross-origin and headless-browser connection attempts in security assessments
- Monitoring WebSocket connection origins, client identities, request volumes, and unusual LLM usage patterns
- Enforcing gateway policies that require approved origins, authentication, rate limits, and restricted network sources
- Using automated security review tools to flag missing WebSocket authentication and origin-validation controls

