[WRONG BRANCH] fix(responses): strip admission bearer from forwarded headers for routed providers - #324
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e163c89d0e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // consume a stored Codex credential still need the caller's admission Authorization removed: | ||
| // some adapters intentionally use forwarded Authorization as their provider credential. | ||
| // Dedicated-header admission remains unchanged because its Authorization belongs upstream. | ||
| const stripAuthorization = options.admission?.source === "bearer" && !substituteMainCredential; |
There was a problem hiding this comment.
Inspect Authorization before preserving it
When a request supplies both a valid x-opencodex-api-key and Authorization: Bearer <another proxy key>, resolveResponsesApiAuth deliberately records the admission source as dedicated, so this condition is false and the proxy bearer remains in the forwarded headers. A routed Cursor provider without its own apiKey, for example, consumes that forwarded value as its upstream token in src/adapters/cursor/live-transport.ts:159-164, exposing an OpenCodex secret despite this fix. Determine whether the actual Authorization value is a proxy admission secret (for example via isProxyAdmissionSecret) instead of relying solely on the winning admission source, while preserving genuinely foreign upstream bearers.
AGENTS.md reference: AGENTS.md:L266-L272
Useful? React with 👍 / 👎.
Motivation
Description
stripAuthorizationoption tomaterializeCodexUpstreamAuthand respected it when buildingselectedForwardHeaders, so admission bearers can be removed before adapter dispatch (src/codex/auth-context.ts).stripAuthorizationfor caller-admitted bearer tokens that are not substituted with a stored Codex credential and pass it intomaterializeCodexUpstreamAuth(src/server/responses/core.ts).tests/codex-auth-context.test.ts).src/server/responses/core.ts,src/codex/auth-context.ts, andtests/codex-auth-context.test.ts.Testing
npx -y bun@1.3.14 test tests/codex-auth-context.test.ts, and the updatedcodex-auth-contexttests passed (including the new case).npx -y bun@1.3.14 run typecheckwhich completed successfully.npx -y bun@1.3.14 run privacy:scanwhich passed.npx -y bun@1.3.14 test tests/bearer-admission-routed-provider.test.ts) in this environment and observed environment-dependent failures (loopback/private-network / 403 and other harness differences) unrelated to the change; the changes are focused and the new unit coverage verifies the intended behavior.npx -y bun@1.3.14 run testwas attempted; many unrelated, environment-sensitive tests failed in this runner (infrastructure / Docker / platform-specific guards), so full-suite failures are considered unrelated to this targeted fix. The focused regression and static checks are green.Codex Task