5 Commits
Author SHA1 Message Date
75adef1e99 fix(http)!: key on the hop the proxy wrote, not the one the client sent (#2)
clientIp returned the FIRST x-forwarded-for hop, with a comment asserting that
was "what the proxy saw" and a test pinning it. Both were wrong in the same
direction.

A reverse proxy APPENDS to X-Forwarded-For. Caddy and nginx both do. So for a
request through one proxy the header reads `<whatever the client sent>, <what
the proxy actually saw>`, and the only entry a client cannot forge is the LAST.

The effect, in every adopter at once: send a random X-Forwarded-For with each
request and every request lands in a fresh bucket, so no bucket ever fills.
Not "weakened" — bypassed completely. A limiter that cannot be tripped is not a
limiter, and it is worse than none, because the route reads as protected.

Found in orangecat's payments audit (bitbaum/orangecat#563, finding 2), where
the same mistake is copied across three payment routes that each mint a real
Lightning invoice per request.

Now counts from the right. `trustedProxies` (default 1) says how many proxies
of your own sit in front; a CDN in front of Caddy is 2 and moves the answer one
further left. `trustedProxies: 0` means the server is exposed directly, so every
forwarded header is client-written and none is evidence — the result is
"unknown" rather than a number that looks like proof.

Verified against the fleet's actual topology rather than assumed: DNS resolves
straight to the box, no CDN, one Caddy 2.11.4 with no trusted_proxies
configured, so exactly one hop is appended.

BREAKING: the returned identity changes behind a proxy — which is the point.
v0.2.0. Adopters pinning #v0.1.0 keep the bypass until they move.


Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
v0.2.0
2026-08-28 19:51:09 +02:00
GandClaude Opus 5 be1c3ba037 docs(ci): the sweep lives in bitbaum/fleet, not dotfiles (#1)
The `uses:` line is already correct. What was stale is the prose next to
it, which told the reader the policy lives in bitbaum/dotfiles and to go
change it THERE. That file no longer exists in dotfiles — the sweep moved
to bitbaum/fleet on 2026-08-28, because a repo holding someone's .bashrc
is not where a fleet's deploy policy belongs.

A comment that misroutes a fix is worse than a missing one: it sends the
next person to edit a repo where the change would reach nobody, which is
the precise failure the shared sweep exists to prevent.

Files: .github/workflows/ci.yml


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 14:02:29 +02:00
Mao Nakamoto b15a5384ae chore(ci): GitHub owner maonakamoto -> catomean 2026-08-27 19:18:38 +02:00
Mao Nakamoto cb5cf21f93 chore(ci): GitHub owner maonakamoto -> catomean 2026-08-27 19:11:26 +02:00
Mao NakamotoandClaude Opus 5 9010598cab feat: limitkit — rate limiting as a decision, extracted from twelve copies
Twelve near-identical rate limiters existed across nine repos of this fleet.
orangecat alone carried four, and its ADR-0002 to unify them sat "Proposed" for
seven months while the count doubled — the measured proof that writing a plan
down is not the same as extracting the code.

What actually varied between the twelve was ONE thing: where the counts live
(eleven in process memory, one in Upstash). Everything else — window
arithmetic, refusal shape, headers, client-IP extraction — was the same idea
written twelve slightly different ways, with independently re-invented bugs.
So the algorithm is fixed and the store is the seam:

  slidingWindow / fixedWindow  pure over store + clock. Both shapes shipped in
                               the fleet, and they refuse differently; the
                               choice is now named at the call site instead of
                               implied by whichever file got copied.
  Store / MemoryStore          two methods. The default is BOUNDED (LRU past
                               maxKeys): one replaced implementation kept a
                               bare Map keyed by stranger IPs with no eviction
                               — a slow memory leak fed by the public
                               internet, now impossible by construction.
  toHeaders / clientIp         the HTTP edges everyone also rewrote. Standard
                               X-RateLimit-* trio, Retry-After on refusals
                               only — exactly what orangecat's ADR specified.

Two decisions worth naming:

  A REFUSAL COUNTS NOTHING. Several replaced implementations let refused
  requests extend the window, so a scripted attacker hammering a key locked
  the legitimate user behind the same NAT out indefinitely. Here a hammered
  key recovers the moment the attacker stops; there is a test for exactly
  this shape.

  retryAfterSeconds IS DERIVED, never fabricated — computed from when the
  oldest counted hit ages out. "Try again shortly" on a window that opens in
  an hour is the same lie ai-ration's 429 classifier exists to prevent, one
  layer down.

Deliberately not included, per SHARED.md's extraction rules: no HTTP client,
no middleware, no framework types, no distributed store (the seam is two
methods; your Redis is your ops posture), and NO LIMIT VALUES — how many
attempts a login route allows is app semantics, asserted locally.

Every function takes `now` as an argument, so all of it is testable without
sleeping — which is why this package has 14 tests and the twelve files it
replaces, collectively, had almost none. Tests import the package BY NAME, so
the exports map is exercised on every run, not at the first consumer's
install.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
v0.1.0
2026-08-20 15:55:38 +02:00