Skip to content

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

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

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

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.34 Backport PR targeting release/2.34 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 12, 2026
Resolve the conflict with #31433 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.34.
@github-actions github-actions Bot removed the stale This issue is like stale bread. label Nov 13, 2026
@denisra
denisra merged commit 9217b14 into release/2.34 Nov 20, 2026
49 of 52 checks passed
@denisra
denisra deleted the backport/29798-to-2.34 branch November 20, 2026 16:20

This branch had an error being deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants