Add rate limiting to the OAuth provider by matthieusieben · Pull Request #5798 · bluesky-social/atproto
Commentaire de pull request · PR #5798 Add rate limiting to the OAuth provider · @github-actions No blocking findings. The PR looks fine.
I reviewed the server side most closely, since the security risk is there. I also skimmed the UI changes.
What I checked
RateLimitManager and the policies
Rules with no points always count as exceeded, since 0 - 1 < 0 . So sign-ups still require a captcha even when rateLimits is unset. That keeps the old behaviour when PDS_RATE_LIMITS_ENABLED is off.
Captcha-tier rules are left out when hCaptcha isn't configured. The PAR policy rejects a captcha tier at construction.
A failed block tier is reported before any hCaptcha verification runs.
No block-tier default is keyed on identifierKey alone, so nobody can lock a victim out. The identifier-only keys sit in the captcha tier, where the worst case is that someone forces captchas on another person's account.
Limiter names include durationMs , so reordering rules can't hand a 5-minute rule the counters of a daily one.
PDS adapter ( packages/pds/src/rate-limits.ts )
xrpc-server's RateLimiter.consume throws RateLimitExceededError when over the limit and returns null when it consumes nothing. The adapter rebuilds an unclamped remainingPoints from consumedPoints , so the manager's < 0 check is correct.
When the backend fails, it logs and lets the request through (fails open), as the docs say.
PAR-only /oauth/authorize
The new request_uri == null check throws InvalidRequestError , not AuthorizationError . So a redirect_uri that was never validated can't be used as an open redirect.
The cookie-test branch now always loads the request from request_uri . The authorize() signature is narrowed to match.
The only remaining 'request' in … check ( oauth-provider.ts:588 ) is on the PAR body, not on the query union that changed. Nothing else in the repo relied on in narrowing.
oauthAuthorizationRequestQuerySchema : each variant uses z.never().optional() on the others' keys. A request_uri together with response_type now parses as the URI variant, and request_uri together with request is rejected, as the changeset says.
hCaptcha
Any verification or network failure becomes captcha_rejected , but an OAuthError thrown by the onHcaptchaResult hook is passed through.
Client tokens with undefined values are dropped by JSON.stringify .
Invite codes on sign-up : inviteCode now always reaches OAuthStore.createAccount , which verifies it when present ( oauth-store.ts:159 ). The changeset documents this behaviour change.
Error headers : getResponseHeaders() replaces the three special cases for WWW-Authenticate , and adds Retry-After to the CORS exposed headers.
UI ( RateLimitedForm )
With no Retry-After , setCountdown(undefined) falls back to 0, so the form isn't left blocked.
The form only re-submits by itself when a submission was waiting for a token, so a passive challenge can't loop.
Changesets : they cover every touched package at suitable bump levels (pre-v1 breaking changes are minor ). AGENTS.md is updated with the new oauth-provider rules.
Minor notes, not blocking
The root package.json verify script gains < /dev/null . It's a harmless tooling tweak, but it has nothing to do with the PR's stated purpose.
A host-supplied rule with durationMs < 1000 would reach the PDS limiter as duration: 0 , which rate-limiter-flexible treats as "never expires". The defaults are all minutes or longer, so this only matters for custom policies.
CI was still running when I reviewed, so I couldn't check its results.
Claude review, run Ouvrir sur GitHub →