Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: normalize path before rate-limit bucket keying (#27273) - #27444

Merged
mtojek merged 2 commits into
release/2.34from
backport/27273-to-2.34
Sep 1, 2026
Merged

fix: normalize path before rate-limit bucket keying (#27273)#27444
mtojek merged 2 commits into
release/2.34from
backport/27273-to-2.34

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Backport of #27273

Original PR: #27273 — fix: normalize path before rate-limit bucket keying
Merge commit: de716f8
Requested by: @jdomeracki-coder

Coder's rate limiter keyed its bucket on the raw, un-normalized request
path (`httprate.KeyByEndpoint` reads `r.URL.Path` directly). The
router's `singleSlashMW` already collapses redundant slashes so a
request like `/api/v2/users//validate-password` reaches the same handler
as the canonical path, but it never touched `r.URL.Path`, so the rate
limiter saw a different key and let a client bypass a limit it had
already hit just by respelling the URL.

`keyByNormalizedEndpoint` replaces `KeyByEndpoint` and runs `path.Clean`
on `r.URL.Path` before using it as the key, so equivalent paths share
one bucket. Includes a unit test at the key-function level and an
integration test (`TestRateLimitPathNormalization`) that reproduces the
bypass against a real server.

Fixes CDM-02-003 (Cure53). Refs
https://github.com/coder/security-disclosures/issues/166.

(cherry picked from commit de716f8)
@github-actions github-actions Bot added the stale This issue is like stale bread. label Aug 7, 2026
@github-actions github-actions Bot closed this Aug 11, 2026
@BobbyHo BobbyHo reopened this Sep 1, 2026
@BobbyHo BobbyHo removed the stale This issue is like stale bread. label Sep 1, 2026
@BobbyHo
BobbyHo requested a review from mtojek September 1, 2026 15:40
@mtojek
mtojek merged commit ac2323f into release/2.34 Sep 1, 2026
47 of 49 checks passed
@mtojek
mtojek deleted the backport/27273-to-2.34 branch September 1, 2026 20:15
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants