fix(coderd): harden oauth2 redirect validation - #27274
#27274Merged
aslilac merged 7 commits intoJul 23, 2026
maincoder/coder:mainfrom
lilac/oauth2-redirect-validationcoder/coder:lilac/oauth2-redirect-validationCopy head branch name to clipboard
Merged
fix(coderd): harden oauth2 redirect validation#27274aslilac merged 7 commits intomaincoder/coder:mainfrom lilac/oauth2-redirect-validationcoder/coder:lilac/oauth2-redirect-validationCopy head branch name to clipboard
aslilac merged 7 commits into
maincoder/coder:mainfrom
lilac/oauth2-redirect-validationcoder/coder:lilac/oauth2-redirect-validationCopy head branch name to clipboard
Conversation
aslilac
commented
Jul 22, 2026
geokat
approved these changes
Jul 22, 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.
Closes DEVEX-604
Hardens
redirectURL handling in the OAuth2/OIDC/external-auth callback flows so redirects are always reduced to a safe, relative path local to the application. Previously a redirect value with an opaque scheme (e.g.javascript:...) or a path with multiple leading slashes (e.g.///evil.com) could survive sanitization mostly intact.Also de-duplicates the previously copy-pasted
uriFromURLhelper (now exportedhttpmw.URIFromURL) so there's a single implementation shared bycoderd/userauth.go,coderd/externalauth.go, andcoderd/httpmw/oauth2.go.Context
Addresses a low-severity finding reported via a pentest disclosure: the redirect sanitizer used
url.Parse(...).RequestURI(), which doesn't reject non-hierarchical (opaque) URLs and doesn't collapse extra leading slashes, so craftedredirectvalues could partially survive sanitization.This PR was authored by a Coder Agent on behalf of @aslilac.