Skip to content

fix(anthropic): refuse redirects on the usage probe and reset-grant requests - #8758

Closed
vadymhimself wants to merge 3 commits into
lidge-jun:devfrom
AgentRadarLabs:fix/anthropic-probe-refuse-redirects
Closed

vadymhimself wants to merge 3 commits into
lidge-jun:devfrom
AgentRadarLabs:fix/anthropic-probe-refuse-redirects

Conversation

@vadymhimself

@vadymhimself vadymhimself commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The OAuth profile probe (src/oauth/anthropic-identity.ts) already passes redirect: "error", and so do the other vendor quota probes in src/providers/quota/. Three other Anthropic requests that send the OAuth bearer still followed redirects:
    • the usage probe in src/providers/claude-cli-usage.ts;
    • the reset-grant status/profile read (getAccountJson) in src/providers/anthropic-reset-grants.ts;
    • the reset-grant claim POST in the same file.
  • Following a redirect could send the bearer to another host. For the claim, a 307/308 would also re-post the claim body there.
  • This change sets redirect: "error" on all three requests. A refused redirect throws, so the existing catches handle it:
    • the usage probe behaves exactly as it does today for a thrown fetch;
    • the read reports upstream;
    • the claim reports the existing unknown outcome. It is never treated as settled.
  • I updated the owning structure docs (structure/gui-and-management-api.md and structure/providers/claude-cli-replay.md).
  • This is carried over from the vadymhimself fork (1f93f91), where it covered the usage and profile probes. The reset-grant requests are new on dev since then.

Verification

All commands used the pinned Bun 1.4.4 with an isolated HOME. Latest validation: head 052e91f32f after merging upstream/dev on 2026-11-17. The latest affected suite passed 54 tests; the 150-test combined run below is the original validation.

  • bun test tests/providers/provider-anthropic-usage-windows.test.ts: 54 pass, 0 fail. With the src/ change reverted, the new test fails (53 pass, 1 fail).
  • bun test on that file plus tests/cli/cli-account-policy.test.ts and tests/cli/cli-anthropic2-account.test.ts: 150 pass, 0 fail.
  • bun scripts/test.ts --changed=upstream/dev: 45,915 pass, 4 fail. The four failures fail the same way on dev and on my earlier PRs:
    • retained sync and serve-options
    • connected-client runtime probe scope
    • end-to-end Home <-> compiled ocx-child lifecycle ×2, where the local Child build fails at cc with exit 69
  • bun run typecheck, bun run structure:check and bun run privacy:scan all pass.
  • There is no wire change for a non-redirect response, so I did not re-run a live measurement.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Security
    • Requests to Anthropic’s usage and reset-grant endpoints now reject redirects rather than following them. If a reset-grant claim is redirected, its outcome is reported as unknown.
  • Documentation
    • Clarified redirect handling for usage checks and reset-grant requests.

…equests

The OAuth profile probe already passes redirect: "error", but the usage probe
in claude-cli-usage.ts and the reset-grant status read and claim POST in
anthropic-reset-grants.ts followed redirects. A redirect must never carry the
OAuth bearer, or a 307/308 re-post of the claim, to another host. A refused
claim redirect lands in the existing unknown-outcome catch.

Carried over from the vadymhimself fork (1f93f91).

Co-Authored-By: Claude Code <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4bb6e6e and 052e91f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Anthropic usage and reset-grant requests now reject redirects. A refused redirect during a reset-grant claim produces AnthropicResetGrantUnknownOutcome. A test checks the redirect option on all three requests, and the documentation describes the behavior.

Changes: Anthropic redirect handling

Layer / File(s) Summary
Reject redirects on Anthropic requests
src/providers/claude-cli-usage.ts, src/providers/anthropic-reset-grants.ts, tests/providers/provider-anthropic-usage-windows.test.ts, structure/providers/claude-cli-replay.md, structure/gui-and-management-api.md
The usage probe and both reset-grant requests set redirect: "error". If a claim redirect is refused, the existing catch throws AnthropicResetGrantUnknownOutcome. The test checks the redirect option for all three requests, and the documentation describes the behavior.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · previous review f28c3

This change stops Anthropic usage and reset-grant requests from following redirects, which keeps the bearer token from being forwarded to another host. Non-redirect behavior is unchanged. The change has a focused test and updated documentation, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(anthropic): refuse redirects on the usage probe and reset-grant requests" names the main change: the Anthropic usage probe and reset-grant requests now use redirect: "error". The raw su…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(anthropic): refuse redirects on the usage probe and reset-grant requests" names the main change: the Anthropic usage probe and reset-grant requests now use redirect: "error". The raw summary confirms the changes in src/providers/claude-cli-usage.ts and src/providers/anthropic-reset-grants.ts, plus matching docs and tests. The title is specific, concise, and free of file lists or vague terms, so it matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d842c13 and f28c318.

Files selected for processing: 5

  • src/providers/anthropic-reset-grants.ts
  • src/providers/claude-cli-usage.ts
  • structure/gui-and-management-api.md
  • structure/providers/claude-cli-replay.md
  • tests/providers/provider-anthropic-usage-windows.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@vadymhimself
vadymhimself marked this pull request as ready for review November 14, 2026 16:53
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request has been marked Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 16, 2026 08:56
@github-actions
github-actions Bot marked this pull request as ready for review November 17, 2026 00:44
lidge-jun added a commit that referenced this pull request Nov 17, 2026
… gate explicit SSH routes (#8868)

Lane R4 of the 2026-11-17 triage round: refuse redirects on Anthropic bearer requests (#8758), keep caller restrictions visible to the Chat tool-dispatch guard (#8814), and require owner authority for explicit SSH routes (#8806).

Co-authored-by: Vadym O <[email protected]>
Co-authored-by: Epinephrine <[email protected]>
@lidge-jun

Copy link
Copy Markdown
Owner

Thank you. This change was carried, with your authorship kept as a Co-authored-by trailer, in #8868, which is now merged into dev as bfdb2bc (2026-11-17 triage round). Closing as superseded; see #8868 for any follow-up changes made during review.

@lidge-jun lidge-jun closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants