-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(components/server): ensure a sane redirect/returnTo query param #4708
Conversation
/werft run 👍 started the job as gitpod-build-leo-safe-redirect-query-param.1 |
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.
@leodido it's awesome that you're on it to fix the situation! 💯
I believe it will be more sustainable to not allow addressing any hosts at all. We should rather rewrite all returnTo=URL
with returnTo=PATH
with the means of appending the path to the known Gitpod host. This way there is no need to parse user values as URL.
@AlexTugarev thanks for your feeback! Would you please take another look at it? :) |
/werft run 👍 started the job as gitpod-build-leo-safe-redirect-query-param.3 |
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.
Code looks good to me!
Let's test before merging 🙏🏻
/werft run 👍 started the job as gitpod-build-leo-safe-redirect-query-param.4 |
@leodido could you rebase please? |
Signed-off-by: Leo Di Donato <[email protected]>
Signed-off-by: Leo Di Donato <[email protected]>
Signed-off-by: Leonardo Di Donato <[email protected]>
fa0087a
to
b923636
Compare
Signed-off-by: Leo Di Donato [email protected]
This PR ensures the value of the
redirect
(orreturnTo
) query parameter is safe.To do so, it strictly checks the value against the allowed URLs (rather than relying on
startsWith
).Furthermore, it uses the
URL
interface to ensure URLs are normalized before checking them.On a side note
My first PR! 🎈
Also, my first Typescript code in years and years (literally!) ... 😊
So please be gentle with me 🙇