Skip to content

fix(review): never send Claude's stored login to a gateway - #823

Open
kixelated wants to merge 5 commits into
mainfrom
quest/m0/review-route-credential
Open

kixelated wants to merge 5 commits into
mainfrom
quest/m0/review-route-credential

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/review-route-credential.md.

Summary

quest review passed ANTHROPIC_BASE_URL to the Claude reviewer even when the environment held no credential for it, so Claude Code sent the user's stored OAuth login to whatever gateway that URL named. Inside a T3 Code session, where the host points ANTHROPIC_BASE_URL at its own gateway and sets CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1, the reviewer instead reported "not logged in", so every agent had to wrap reviews in env -u ANTHROPIC_BASE_URL.

prepare() in src/cli/review.ts now:

  • Under a host-managed provider (CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST set to a value Claude Code treats as on): drops every route, connection setting, and credential from the environment and reviews on the stored login. The flag itself was already stripped. With no stored login, it fails as logged out, and the error says it ignored the host's route.
  • With ANTHROPIC_BASE_URL set, no cloud provider switched on, and no gateway credential: refuses before Claude Code runs, even before its status check. The error names what to set: ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, an Authorization header in ANTHROPIC_CUSTOM_HEADERS, or unsetting the URL. Like a logout, this passes the round over every Claude model.

--help and the README describe both.

Choices made (for review)

  • An Authorization header in ANTHROPIC_CUSTOM_HEADERS counts as a gateway credential. Tested against Claude Code 2.1.325: it replaces the stored login's bearer, and the OAuth token appears in no header. Any other custom header, such as X-Api-Key or a tenant header, still let the OAuth bearer through, so only Authorization counts. Header names match case-insensitively, one Name: value per line.
  • CLAUDE_CODE_OAUTH_TOKEN alone is not a gateway credential. It is a login, and sending it to a gateway is the leak itself. When it sits beside a real gateway credential it still passes; the test below shows the gateway credential wins.
  • A cloud provider switch skips the check. With CLAUDE_CODE_USE_BEDROCK=1, ANTHROPIC_BASE_URL received no requests.
  • A host-managed provider also drops cloud switches, custom headers, and credentials, not just the URL: the host set them all, and the plan rejected passing the host's credential through.

Validation

  • Reproduced the leak first. A local listener logged request headers while claude -p ran with ANTHROPIC_BASE_URL pointed at it:

    • with no credential, it received Authorization: Bearer sk-ant-oat01-… (the stored OAuth login), three times;
    • with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1, claude auth status reported loggedIn: false and the run printed "Not logged in".
  • Real CLI, bare gateway. env -u CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST quest review --harness claude exited 3 with the new error before launching Claude.

  • Real CLI, inside this T3 session (host-managed flag and ANTHROPIC_BASE_URL set). reviewerEnvironment("claude", …) returned no ANTHROPIC_* or CLAUDE_* variables, and claude -p with that environment replied ok on the stored login. No env -u was needed.

  • Second, independent check: a sweep against real Claude Code. For each environment, the reviewer environment prepare() builds was run against the header-logging listener:

    Environment Result
    no credential refused
    tenant header only refused
    CLAUDE_CODE_OAUTH_TOKEN only refused
    Authorization custom header 3 requests, no OAuth token
    ANTHROPIC_AUTH_TOKEN 6 requests, no OAuth token
    ANTHROPIC_API_KEY 6 requests, no OAuth token
    ANTHROPIC_AUTH_TOKEN + CLAUDE_CODE_OAUTH_TOKEN 6 requests, no OAuth token
  • Tests. New fake-CLI tests cover the bare gateway (logged in and logged out), the Authorization header, a cloud switch, and host-managed sessions with and without a stored login. All four bare-gateway and host-managed tests fail against the old review.ts.

  • just check and just test pass: 1581 tests passed, 5 skipped.

Public API

Behavior change, no !. quest review and reviewerEnvironment now refuse a Claude gateway with no credential (previously they sent the stored login), and drop a host-managed provider. No wire impact.

Caused by

  • moq-dev/quest#424 - started passing ANTHROPIC_BASE_URL to the reviewer without requiring a credential for the gateway (found by person)

Follow-ups

  • quest/m0/review-codex-gateway-credential.md [S] - Codex has the same leak. Given openai_base_url and no key, Codex 0.167.1 sent its stored ChatGPT login (Bearer <JWT> and chatgpt-account-id) to a local listener. With a stored login, quest review also strips CODEX_API_KEY, so a gateway's key loses to that login. This quest's Goal covers only Claude, and Codex needs its own decision about the status check (codex login status ignores CODEX_API_KEY). Kept by the maintainer: ✅ keep (rejected: drop), pick round.

Decisions

  • Pick (2026-11-22, maintainer, pick round): ✅ /quest-merge (rejected: /quest-iterate, skip).
  • Follow-up quest/m0/review-codex-gateway-credential.md: ✅ keep (rejected: drop), recorded in its Plan.

Related

  • quest/m0/benchmark/review-not-ci.md is being implemented beside this and also edits src/cli/review.ts, in reviewer routing by risk rather than prepare(). Expect a merge if it lands first.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, XS, arm A)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 3597891

  • Base: origin/main at 1fa61e8

  • Risk: high, It changes the credentials `quest review` gives the Claude reviewer: under CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST it now strips the host's gateway route, provider switches, and credentials and runs on the stored login, and a gateway with no credential is refused before launch, which breaks existing T3 Code and gateway review setups; a revert restores the old routing, but reviews already run on the changed credentials until then, so the reviewer's credentials are what it changes.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session e30e160c-903b-46ef-9617-33aec2f2c4a0

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a2054e-f954-7571-9f4a-c607c7087d13, round 3

  • Score: 9/10, The incremental change only records a maintainer decision in a quest document and introduces no actionable issues; runtime validation of the overall change remains unverified.

  • Rounds: 3; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Reviewer: Claude Code, claude-sonnet-5-5, medium effort, second

  • Session: 133acced-44be-49b7-a826-50f88e5886d9, round 3

  • Score: 8/10, Since the last review the only change is a plan note in a quest file recording that the Codex follow-up is kept, so no new findings arise and the earlier concerns stay settled.

  • Rounds: 3; first round 8 (high 1, medium 4, low 3); findings 8 (high 1, medium 4, low 3): fixed 3, refuted 5, open 0

  • Findings: none

  • Reviewer: Codex, gpt-6.1-sol, high effort, shadow

  • Session: 01a2054e-f954-7470-a0f9-6b7be0a540cf

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

kixelated and others added 3 commits November 22, 2026 13:52
…st-managed provider

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title quest review never sends a login to a gateway fix(review): never send Claude's stored login to a gateway Nov 22, 2026
…s to Claude

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 22:19
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1d41339-8e45-4f4f-a058-05276a5518f7
Commits

Reviewing files that changed from the base of the PR and between 470157d and 3597891.

Files selected for processing: 7

  • README.md
  • quest/m0/review-codex-gateway-credential.md
  • quest/m0/review-route-credential.md
  • src/cli/main.ts
  • src/cli/review.ts
  • test/review-fakes.ts
  • test/review.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (2026-11-22, /quest-run, pick round):

  • Pick: ✅ /quest-merge (rejected: /quest-iterate, skip).
  • Follow-up quest/m0/review-codex-gateway-credential.md: ✅ keep (rejected: drop).

(Written by Opus 5.5)

pullfrog[bot]
pullfrog Bot previously approved these changes Nov 22, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. The check sits in prepare(), which builds every Claude reviewer environment. So the stored login can't reach a gateway with no credential on any path, and a host-managed session runs on the stored login without env -u.

Reviewed changes

This run reviewed the full PR at 087f904. That covers the prepare() routing change, its docs and help text, the new tests, and the quest bookkeeping.

  • Host-managed provider: when CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST is truthy, prepare() runs strippedEnvironment(userEnv) before anything else. That drops every ANTHROPIC*/CLAUDE* variable except CLAUDE_CONFIG_DIR, so the review uses the stored login. The logged-out error now says the host's route was ignored.

  • Bare-gateway refusal: bareGateway refuses before Claude Code runs, even before its status check, when all of these hold: ANTHROPIC_BASE_URL is set, no CLAUDE_CODE_USE_* switch is on, and there is no ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, or Authorization line in ANTHROPIC_CUSTOM_HEADERS. It throws ReviewerUnavailableError with the reason "gateway without credential", so the round passes over every Claude model as a logout does. Skip reasons are free-form strings in review-record.ts, so the new reason needs no parser change.

  • Helpers: enabled/claudeProviders pull out the switch test that routes already used. authorizes matches the header name case-insensitively and needs a non-empty value.

  • Docs and help: the README and --help describe both behaviours and limit the claim to Claude.

  • Tests: new fake-CLI tests cover:

    • a bare gateway, logged in and logged out, including a tenant header, an X-Authorization decoy, and CLAUDE_CODE_OAUTH_TOKEN
    • an Authorization header passing
    • a cloud switch skipping the check
    • host-managed sessions with and without a stored login

    test/review.test.ts passes locally (111/111).

  • Quests: the finished quest is removed, and quest/m0/review-codex-gateway-credential.md tracks the same leak in Codex.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Applied the pick round's decision: the keep of quest/m0/review-codex-gateway-credential.md is recorded in that quest's Plan (3597891) and in this PR's ## Decisions and ## Follow-ups. The head changes only that quest file since the reviewed head, so the review record still counts. Pullfrog's approval left no findings to answer. Not merged or queued here; the /quest-merge pick stands.

(Written by Claude Opus 5.5)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run reviewed the delta since 087f904.

  • Quest note: recorded the maintainer's keep decision in the Plan of quest/m0/review-codex-gateway-credential.md. It is documentation only, with no code change.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant