Skip to main content
← Back to list
01Issue
BugShippedSwamp Club
Assigneeskeeb

Relationships

#1093 swamp-club: global rate limiter runs pre-auth and collapses all direct clients into one per-IP bucket — 429s authenticated CLI traffic

Opened by keeb · 7/11/2026· Shipped 7/17/2026

Description

Since #726 (17ca034, expand rate limiting to global middleware), routes/_middleware.ts calls checkRateLimit(getGlobalRateLimiter(), ctx.req, null) BEFORE auth resolution. Consequences:

  1. The /api/ rule (120 req/min, all methods) applies to authenticated traffic too — the userId passed is always null at that point, so requireAuth-style exemptions can't work in the global limiter.
  2. extractClientIp only reads x-forwarded-for and falls back to "unknown", so in any deployment without a proxy setting XFF, ALL clients share a single rate-limit bucket.
  3. The CLI surfaces every 429 as "Rate limit exceeded... Sign in with 'swamp auth login' for a higher limit" — misleading, because signing in does not raise the global ceiling.

Steps to Reproduce

  1. Run swamp-club directly (no reverse proxy)
  2. Authenticate a CLI and issue >120 API requests within 60s (e.g. parallel swamp extension pull/search across repos)

Observed: 429s on authenticated requests; all clients throttle together regardless of origin.

Impact

The UAT extension suite (~65 tests driving parallel CLI clients against one registry) fails wholesale. Any automation-heavy authenticated user behind NAT hits the same wall in production.

Suggested Direction (needs a design decision)

  • Short term: an env override for test/self-hosted deployments (verified locally with a RATE_LIMIT_DISABLED=1 setting that empties the rule set; production defaults unchanged)
  • Longer term: resolve auth (cached) before the global limiter or give authenticated principals per-key buckets/higher ceilings, and fix the "unknown" shared-bucket fallback
  • CLI: only show the sign-in hint when the 429 actually came from an unauthenticated-only rule

Environment

swamp-club main (0abbb2f), swamp main (c3fd7b11), Linux x86_64

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 3 MOREPR_MERGED+ 1 MORENOTIFICATION_SKIPPED

Shipped

7/17/2026, 11:56:57 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
keeb assigned keeb7/17/2026, 10:17:45 PM

Sign in to post a ripple.