Pin the rate-limit key for an empty RemoteAddr (closes #168) #448

Merged
clawbot merged 1 commits from issue-168-empty-remoteaddr into next 2026-10-02 17:09:23 +02:00
Collaborator

A request with an empty RemoteAddr cannot be read as an address, so the rate-limit key function falls back to the raw value and keys on the empty string: every such request shares one bucket across all four limiters. Following the plan on #168 (option 1), that behaviour stays as it is, since it fails closed and net/http never leaves RemoteAddr empty for a TCP listener.

  • A new test in internal/middleware/ratelimit_test.go pins it: an empty RemoteAddr keys on the empty string.
  • The comment at the fallback in clientKey now says the empty case is distinct from the Unix-socket case (only a hand-built request carries it) but fails closed the same way.

No behaviour change.

Model: opus-5-5

A request with an empty `RemoteAddr` cannot be read as an address, so the rate-limit key function falls back to the raw value and keys on the empty string: every such request shares one bucket across all four limiters. Following the plan on https://git.eeqj.de/sneak/webhooker/issues/168 (option 1), that behaviour stays as it is, since it fails closed and `net/http` never leaves `RemoteAddr` empty for a TCP listener. - A new test in `internal/middleware/ratelimit_test.go` pins it: an empty `RemoteAddr` keys on the empty string. - The comment at the fallback in `clientKey` now says the empty case is distinct from the Unix-socket case (only a hand-built request carries it) but fails closed the same way. No behaviour change. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 16:57:36 +02:00
clawbot self-assigned this 2026-10-02 16:57:36 +02:00
clawbot added 1 commit 2026-10-02 16:57:37 +02:00
A request with an empty RemoteAddr falls through to the raw-value
fallback and keys on the empty string, so every such request shares
one bucket. That is the fail-closed direction and stays as it is. A
test now pins it, and the comment at the fallback tells it apart from
the Unix-socket case.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit c22ca6218e into next 2026-10-02 17:09:23 +02:00
clawbot deleted branch issue-168-empty-remoteaddr 2026-10-02 17:09:24 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#448