Skip to content

Quota HTTP client follows redirects while holding provider credentials #38

Description

@ascendedent

Summary

quota_http_json() in token_meter/quotas/common.py uses stdlib urlopen, which follows redirects.

Claude sends Authorization: Bearer <oauth access token>. Cursor sends Cookie: WorkosCursorSessionToken=…. Codex OAuth sends a bearer token to chatgpt.com.

Python 3.11+ strips Authorization on cross-host redirects. It does not strip Cookie. Older Python may forward Authorization as well.

Endpoints are fixed today (api.anthropic.com, chatgpt.com, cursor.com), so this is not open SSRF. It is still “if the provider (or a future URL change) 302s, credentials leave the intended host.”

Error handling here is otherwise careful (size cap, sanitized QuotaUnavailable messages, tests in tests/contracts/test_quota_privacy.py).

Suggested fix

Use an opener whose redirect handler refuses to follow, and fail closed. Optionally pin the final URL.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions