Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
mtojek merged 1 commit into
release/2.33from
backport/27274-to-2.33
Jul 27, 2026
Merged

fix(coderd): harden oauth2 redirect validation (#27274)#27462
mtojek merged 1 commit into
release/2.33from
backport/27274-to-2.33

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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.33 branch from 94da85c to 20cf53a Compare July 23, 2026 18:03
@aslilac aslilac changed the title fix(coderd): harden oauth2 redirect validation (#27274) (conflicts) fix(coderd): harden oauth2 redirect validation (#27274) Jul 23, 2026
@mtojek
mtojek merged commit 5bdaf6b into release/2.33 Jul 27, 2026
42 checks passed
@mtojek
mtojek deleted the backport/27274-to-2.33 branch July 27, 2026 07:26
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants