Repository navigation
fix(coderd/httpmw): anchor CSRF exemption patterns (#31125) - #31433
Merged
Merged
Conversation
fix(httpmw): restrict CSRF exemptions to intended routes CSRF exemptions used shell-style patterns evaluated as unanchored regexes, allowing unintended cookie-authenticated routes to bypass protection. This enabled CSRF against role-management routes containing `derp` and dev container recreate/delete endpoints. - Anchor exemptions to their intended routes or subtrees. - Remove the broad workspace-agent exemption, duplicate first-user entry, and obsolete `/api/v2/scim` pattern. - Preserve intended exemptions and requests without session cookies, keeping agents, proxies, provisioners, and SCIM providers unaffected. - Add regression tests for unintended matches, legitimate exemptions, requests without session cookies, and rejection of a cross-origin request to a formerly exempt route. Validation: `go test ./coderd/httpmw/ -count=1`, `go vet`, and `golangci-lint run ./coderd/httpmw/...` pass. Backports: Omit the doubled-leading-slash test on branches without #29798. Refs [PLAT-733](https://linear.app/codercom/issue/PLAT-733) (cherry picked from commit 0fd0775)
BobbyHo
force-pushed
the
backport/31125-to-2.34
branch
from
October 31, 2026 18:23
b7e44c7 to
07c3d2c
Compare
denisra
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #31125
Original PR: #31125 — fix(coderd/httpmw): anchor CSRF exemption patterns
Merge commit: 0fd0775
Requested by: @BobbyHo
Warning
The automatic cherry-pick had conflicts.
Please resolve manually by cherry-picking the original merge commit: