-
Notifications
You must be signed in to change notification settings - Fork 152
Redirect requests with repeated slashes #863
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
Redirect requests with repeated slashes #863
Conversation
🦋 Changeset detectedLatest commit: d998bb8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@dnewbound0 I'm sorry but i don't understand what you're trying to solve here. |
(i've replied to this in the OpenNext discord already but i figured i'd post my response here as well for posterity) i can recreate this using OpenNext v3.6.1, SST v2.48.5, and Next.js v14.2.28. making a request to
new URL("//evil.com", "http://yourdomain.com//evil.com") so you're going to a get a middleware invocation where request.url === "http://evil.com" .
the PR isn't trying to change any functionality about redirecting within the middleware function, but to avoid calling the middleware entirely with that bad path. so it would go:
as far as i can tell, this is how the default NextJS server handles this case? apologies if i've missed something obvious here, this is my first PR and i'm just trying to resolve something that i noticed in our deployment 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 little nit, after that we should be good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR
Let's say you had the following middleware function:
A request to
https://yourdomain.com//evil.com
would result inrequest.url === "https://evil.com"
, leading to a malicious redirect. Here we redirect these bad requests containing repeated slashes to a sanitised path.