Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(coderd): harden oauth2 redirect validation - #27274

#27274
Merged
aslilac merged 7 commits into
maincoder/coder:mainfrom
lilac/oauth2-redirect-validationcoder/coder:lilac/oauth2-redirect-validationCopy head branch name to clipboard
Jul 23, 2026
Merged

fix(coderd): harden oauth2 redirect validation#27274
aslilac merged 7 commits into
maincoder/coder:mainfrom
lilac/oauth2-redirect-validationcoder/coder:lilac/oauth2-redirect-validationCopy head branch name to clipboard

Conversation

@aslilac

@aslilac aslilac commented Jul 15, 2026

Copy link
Copy Markdown
Member

Closes DEVEX-604

Hardens redirect URL 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 uriFromURL helper (now exported httpmw.URIFromURL) so there's a single implementation shared by coderd/userauth.go, coderd/externalauth.go, and coderd/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 crafted redirect values could partially survive sanitization.

This PR was authored by a Coder Agent on behalf of @aslilac.

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

DEVEX-604

Comment thread coderd/httpapi/redirect.go Outdated
Comment thread coderd/httpapi/redirect.go Outdated
Comment thread coderd/httpapi/redirect_test.go
Comment thread coderd/httpapi/redirect.go
@aslilac
aslilac merged commit 2f87991 into main Jul 23, 2026
28 checks passed
@aslilac
aslilac deleted the lilac/oauth2-redirect-validation branch July 23, 2026 17:56
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.