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) - #27464

#27464
Merged
mtojek merged 1 commit into
release/2.35coder/coder:release/2.35from
backport/27274-to-2.35coder/coder:backport/27274-to-2.35Copy head branch name to clipboard
Jul 27, 2026
Merged

fix(coderd): harden oauth2 redirect validation (#27274)#27464
mtojek merged 1 commit into
release/2.35coder/coder:release/2.35from
backport/27274-to-2.35coder/coder:backport/27274-to-2.35Copy head branch name to clipboard

Conversation

@aslilac

@aslilac aslilac commented Jul 23, 2026

Copy link
Copy Markdown
Member

Backport of #27274

Original PR: #27274 — fix(coderd): harden oauth2 redirect validation
Merge commit: 2f87991
Requested by: @aslilac

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`.

<details>
<summary>Context</summary>

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.

</details>

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

(cherry picked from commit 2f87991)
@aslilac
aslilac force-pushed the backport/27274-to-2.35 branch from bd34624 to 17a3b2b Compare July 23, 2026 18:21
@aslilac
aslilac changed the base branch from main to release/2.35 July 23, 2026 18:21
@aslilac aslilac added the cherry-pick/v2.35 Cherry-pick PR targeting release/2.35 label Jul 23, 2026
@mtojek
mtojek merged commit 65e2bfb into release/2.35 Jul 27, 2026
14 of 15 checks passed
@mtojek
mtojek deleted the backport/27274-to-2.35 branch July 27, 2026 07:28
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.35 Cherry-pick PR targeting release/2.35

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

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