fix(proxy): strip x-api-key and provider-specific auth headers from hop-by-hop list - #73640
fix(proxy): strip x-api-key and provider-specific auth headers from hop-by-hop list#73640necoweb3 wants to merge 1 commit into
Conversation
…l leak The proxy replaces the client's Authorization header with its own resolved bearer token, but did not strip provider-specific auth headers (x-api-key, api-key, x-goog-api-key, etc.). A client sending one of these headers would have the real API key forwarded to the upstream server. Add all known provider-specific auth headers and cookie/set-cookie to _HOP_BY_HOP_HEADERS so they are stripped before forwarding.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing the inbound credential-forwarding path; current main does copy non-denylisted request headers upstream through hermes_cli/proxy/server.py:65-72 and uses them at hermes_cli/proxy/server.py:144-145.
Problems
- The stated new credential-header test is not present in PR #73640: its diff modifies only
hermes_cli/proxy/server.py. The existing integration test attests/hermes_cli/test_proxy.py:344-365verifies onlyAuthorization, and the fake upstream attests/hermes_cli/test_proxy.py:293-302does not record the added header names.
Suggested changes
- Add a real proxy-to-fake-upstream regression test in
tests/hermes_cli/test_proxy.pythat records and rejects each newly denylisted credential header while retaining the adapter-generatedAuthorizationheader.
This is an automated hermes-sweeper review.
| "authorization", # we replace this one | ||
| # Provider-specific auth headers that could carry client credentials. | ||
| "x-api-key", # Anthropic native, Google AI Studio | ||
| "api-key", # Azure OpenAI |
There was a problem hiding this comment.
Please add the corresponding real proxy-to-upstream regression test. The existing test only proves Authorization replacement (tests/hermes_cli/test_proxy.py:344-365), and this PR's diff contains no test change for the newly denylisted headers.
|
looks mergeable Reviewed the local OAuth proxy change. The request-forwarding sink now filters client Authorization, provider-specific credential, and session-cookie headers case-insensitively before inserting the adapter bearer, while ordinary request metadata remains forwarded. Current-main comparison confirmed the prior omission of x-api-key and api-key, and validation of the change confirmed removal of every added credential header. No alternate header-forwarding path or bypass was found in the proxy package; no source-backed security finding remains. Security evidence:
Review setup: I reviewed a run-owned local rebase or patch replay against current GitHub Not checked:
Signed: GPT-5.6-luna-max in Codex |
Summary
hermes_cli/proxy/server.py forwards HTTP requests to local model servers. The _HOP_BY_HOP_HEADERS set strips only the standard Authorization header, so non-standard provider auth headers (x-api-key, api-key, x-goog-api-key, cookie, set-cookie, and others) are passed through unchanged to the upstream.
Impact
An attacker controlling the proxy target (or eavesdropping on the proxy->upstream link) can harvest these credentials. OpenAI-compatible clients use Authorization (already stripped), but non-standard clients (Anthropic-style x-api-key, Google x-goog-api-key) are exposed.
Fix
Add all known provider-specific auth headers plus cookie/set-cookie to _HOP_BY_HOP_HEADERS. Defense-in-depth: even if a client sends x-api-key to the proxy, the proxy strips it before forwarding.
Tests