Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce configured host on user supplied returnTo #557

Merged
merged 2 commits into from Dec 15, 2021
Merged

Enforce configured host on user supplied returnTo #557

merged 2 commits into from Dec 15, 2021

Conversation

adamjmcgrath
Copy link
Contributor

Description

This PR changes how the user supplied returnTo param from /api/auth/login is sanitized.

Instead of using a regexp like a block list to prevent URLs that aren't relative from being accepted, it converts the URL to absolute using the configured redirect_uri as a base. It then enforces that the absolute URL has the same origin as the configured redirect_uri.

This will ensure that only valid URLs with the same origin as the configured redirect_uri (or baseURL) are accepted as returnTo URLs.

References

Fixes #545
See also #555

Testing

Tested using https://github.com/adamjmcgrath/open-redirect-finder

@adamjmcgrath adamjmcgrath requested a review from a team as a code owner December 14, 2021 11:38
@vercel
Copy link

vercel bot commented Dec 14, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/auth0/nextjs-auth0/Dbzo2rT8j7GgFr2vsAib7PTYst7a
✅ Preview: Canceled

[Deployment for fe0673c canceled]

Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

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

The implementation looks good, just there are some improvement opportunities in the tests.

@Widcket Widcket merged commit 0bbd9f8 into main Dec 15, 2021
@Widcket Widcket deleted the or-fix branch December 15, 2021 16:24
@adamjmcgrath adamjmcgrath mentioned this pull request Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When somewhere in the returnTo Url a absolute url found -> Exeption
2 participants