fix(proxy): recognise any auth scheme, not just Bearer - #220
Merged
Conversation
The credentialed rate-limit bucket added in #212 only matched `Authorization: Bearer`. The wallet extension signs its requests with `Authorization: Wallet <walletId>:<signature>:<timestamp>`, so every call it made fell through to the anonymous 60/min per-IP bucket. A bulk payout spends one prepare-tx plus one broadcast per payment, so that ceiling is reached around the thirtieth payment and the rest fail with 429 — the same wall #212 was meant to remove, still standing for the one caller that needed it most. Match any scheme and take the credential that follows. A bare `Authorization: Bearer` with no token still yields null, so the anonymous bucket keeps covering junk headers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap
#212 gave credentialed callers their own rate-limit bucket, keyed off
Authorization: Bearer …orX-API-Key.The wallet extension uses neither. It signs with:
(
packages/extension/src/core/api.ts:176)So every request the extension made fell through to the anonymous 60/min per-IP bucket — the exact ceiling #212 was written to remove, still standing for the one caller that needed it most.
A bulk payout spends one
prepare-txplus onebroadcastper payment, so 60 calls is roughly 30 payments. Past that the run fails withRequest failed with status 429, which is what the payer is still seeing mid-batch.The fix
Match any auth scheme and take the credential that follows, rather than hardcoding
Bearer. That coversWallet,Bearer, and anything added later without another round of this.A bare
Authorization: Bearerwith no token still returns null, so junk headers stay on the anonymous bucket — there's an existing test pinning that, and it still passes.Tests
src/proxy.test.ts— 13 passed. New:Wallet <id>:<sig>:<ts>shapeWallet-scheme caller clears 200 requests to/api/web-wallet/:id/broadcast, where it previously stopped at 60Fourth in the chain: #211 (web-wallet caps), #212 (credentialed bucket), #213 (provider hang), this.
🤖 Generated with Claude Code