Skip to content

fix(coderd/httpmw): normalize repeated slashes before CSRF exemption check (#29798) - #30108

Merged
denisra merged 3 commits into
release/2.37from
backport/29798-to-2.37
Nov 20, 2026
Merged

denisra merged 3 commits into
release/2.37from
backport/29798-to-2.37

Conversation

@coder-backporter-app

Copy link
Copy Markdown

Backport of #29798

Original PR: #29798 — fix(coderd/httpmw): normalize repeated slashes before CSRF exemption check
Merge commit: 6372f67
Requested by: @jdomeracki-coder

…check (#29798)

The CSRF middleware decides whether to protect a request based on the
raw URL path, but the router collapses repeated slashes before matching.
A path like `/oauth2//authorize` or `//api/v2/...` reaches the real
handler while skipping CSRF checks.

- Normalize the path before the exemption check, the same way `cors.go`
already does.
- Add test cases for respelled `/api` and `/oauth2/authorize` paths.

Fixes
https://linear.app/codercom/issue/PLAT-672/csrf-exemption-bypass-via-path-respelling-post-oauth2authorize-forges

(cherry picked from commit 6372f67)
@coder-backporter-app coder-backporter-app Bot added the backport/v2.37 Backport PR targeting release/2.37 label Sep 29, 2026
@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Sep 29, 2026
@github-actions github-actions Bot added the stale This issue is like stale bread. label Nov 5, 2026
@github-actions github-actions Bot closed this Nov 8, 2026
@Lisa-Fiander Lisa-Fiander reopened this Nov 9, 2026
@github-actions github-actions Bot removed the stale This issue is like stale bread. label Nov 10, 2026
Resolve the conflict with #31431 in csrf_test.go by keeping both sets
of test cases. Define repeatedSlashesRe in csrf.go, because the
definition in cors.go comes from #29143, which is not on release/2.37.
@denisra
denisra merged commit 88940ff into release/2.37 Nov 20, 2026
32 of 33 checks passed
@denisra
denisra deleted the backport/29798-to-2.37 branch November 20, 2026 16:03

This branch had an error being deployed

1 failed deployment
docs-preview — 8ddd2e55 Deployed Nov 20, 2026 by denisra via cleanup #285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.37 Backport PR targeting release/2.37 community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants