You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Click the link, your browser will open /example.com
What is expected?
It should trigger an error. Whether not a valid URL or not the same origin or redirect to /.
Or it should redirects to //example.com (removing line breaks)
What is actually happening?
The browser opens http://example.com
The bug was reported to us by a bug hunter.
One of our URL https://dashboard.mailmeteor.com/login?redirect=%2F was affected by the bug. If you share a URL to Mailmeteor having a line break in it, such as https://dashboard.mailmeteor.com/login?redirect=%2F%0D%0A%2Fexample.com, our application was redirecting to the distant domain. This has been fixed on our application by preventing redirection to URLs with multiple lines.
While looking at the source of this issue, turns out that vue-router codebase defaults to window.location.replace in case the history.replaceState methods triggers an error. See here:
And window.location.replace(url) has a "bug" that when you provide a url with a line break, it redirects to the last line:
var url = `/
/example.org`
window.location.replace(url) // opens "example.org"
The text was updated successfully, but these errors were encountered:
Frenchcooc
changed the title
Vue-router defaults to window.location on error triggers an issue with
URL with line breaks are not properly managed
May 3, 2022
I pushed a fix for this particular case because it is so easy to get wrong in userland but note that redirecting to a user-provided URL can always present a security risk. The app is responsible for sanitizing it if it wants to display it somewhere
Version
3.5.3
Reproduction link
codesandbox.io
Steps to reproduce
From Codesandbox reproduction link:
example.org
Locally:
/example.com
What is expected?
It should trigger an error. Whether not a valid URL or not the same origin or redirect to
/
.Or it should redirects to
//example.com
(removing line breaks)What is actually happening?
The browser opens
http://example.com
The bug was reported to us by a bug hunter.
One of our URL
https://dashboard.mailmeteor.com/login?redirect=%2F
was affected by the bug. If you share a URL to Mailmeteor having a line break in it, such ashttps://dashboard.mailmeteor.com/login?redirect=%2F%0D%0A%2Fexample.com
, our application was redirecting to the distant domain. This has been fixed on our application by preventing redirection to URLs with multiple lines.While looking at the source of this issue, turns out that vue-router codebase defaults to
window.location.replace
in case thehistory.replaceState
methods triggers an error. See here:vue-router/src/util/push-state.js
Line 40 in 677f3c1
And
window.location.replace(url)
has a "bug" that when you provide a url with a line break, it redirects to the last line:The text was updated successfully, but these errors were encountered: