Skip to content

evil host redirect hanlding for pentest#9398

Open
NamanMahor wants to merge 2 commits into
mainfrom
namanmahor/plat-473-pentest-remove-open-redirects-in-auth
Open

evil host redirect hanlding for pentest#9398
NamanMahor wants to merge 2 commits into
mainfrom
namanmahor/plat-473-pentest-remove-open-redirects-in-auth

Conversation

@NamanMahor
Copy link
Copy Markdown
Contributor

@NamanMahor NamanMahor commented May 6, 2026

PLAT-473: Pentest: Remove open redirects in auth

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@NamanMahor NamanMahor requested a review from begelundmuller May 14, 2026 06:09
@NamanMahor NamanMahor marked this pull request as ready for review May 14, 2026 06:09
@NamanMahor NamanMahor requested a review from himadrisingh May 14, 2026 06:28
Comment on lines 179 to +195
if redirect != "" {
if !a.admin.URLs.IsSafeRedirectURL(redirect, host) {
// The redirect is not on a primary/canonical host and not on the request host.
// The only legitimate case is the server-generated second call in the custom
// domain login flow (canonical domain, custom_domain_flow=true), where the
// redirect points to <custom-domain>/auth/custom-domain-callback.
if !customDomainFlow {
http.Error(w, "invalid redirect parameter", http.StatusBadRequest)
return
}
parsed, _ := url.Parse(redirect)
_, err := a.admin.DB.FindOrganizationByCustomDomain(r.Context(), parsed.Host)
if errors.Is(err, database.ErrNotFound) {
http.Error(w, "invalid redirect parameter", http.StatusBadRequest)
return
} else if err != nil {
http.Error(w, "internal server error", http.StatusInternalServerError)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff and nested logic in this PR is getting quite hard to follow. Firstly, there's calls to FindOrganizationByCustomDomain in two different places. Secondly, I'm not quite following the value of additionalHost since for non-Rill hosts, I would expect the lookup for FindOrganizationByCustomDomain to be sufficient?

Can you perhaps pull all the safe redirect logic, including the custom domain lookup, into a single utility function in this package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants