Replies: 2 comments
-
The flow is as follows: Line 43 in 0f132de https://github.com/nextauthjs/next-auth/blob/beta/src/lib/parse-url.ts next-auth/src/core/lib/callback-url.ts Lines 25 to 34 in 0f132de next-auth/src/core/lib/default-callbacks.ts Lines 7 to 11 in 0f132de |
Beta Was this translation helpful? Give feedback.
-
Thanks for the references 🙏 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description 🐜
First off, thanks for a really nice lib! 🙏
@iaincollins explains very well in #591 (comment) that the baseUrl is checked to prevent malicious sites (clones) to steal credentials from your users. However, since baseUrl dont include an ending "/" even though one is provided to
NEXTAUTH_URL=http://localhost:3000/
like so. This would make it possible to redirect to for examplehttp://localhost:30001
on the localhost example. But in production ifhttps://example.com
is the baseUrl that makeshttps://example.companyevilcredentialstealers.com
a valid redirect as well since it checks with"https://example.companyevilcredentialstealers.com".startsWith("https://example.com")
, and that is true.I'm sure somewhere the urls are parsed/created with new URL(). If so, using the
href
should always return the full url with the ending "/"My simple workaround for now looks like this:
Is this a bug in your own project?
No
How to reproduce ☕️
Just go to https://next-auth-example.vercel.app and try for yourself.
Entering a callback url like this for example
Will redirect you to
This is not an existing domain of course. But it could be if you owned the evilcredentialstealers.org domain and registered
next-auth-example.vercel.app
as a subdomain.Screenshots / Logs 📽
No response
Environment 🖥
System:
[Irrelevant]
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Browser:
Chrome: 96.0.4664.45
npmPackages:
next: 11.1.2 => 11.1.2
next-auth: ^4.0.0-beta.6 => 4.0.0-beta.6
react: 17.0.2 => 17.0.2
Contributing 🙌🏽
Yes, I am willing to help solve this bug in a PR
Beta Was this translation helpful? Give feedback.
All reactions