Skip to content

Conversation

berkos
Copy link

@berkos berkos commented Oct 26, 2023

👋 Thanks for the review in advance.
Fixes open redirect for Rails 7.0
https://api.rubyonrails.org/classes/ActionController/Redirecting.html#method-i-redirect_to-label-Open+Redirect+protection

The PR here follows a similar approach with #318
Please ensure your pull request includes the following:

@berkos berkos changed the title Allow open redirect for Rails 7.0 Allow open redirect for Rails 7.0 in #redirect_back_or_to method Oct 26, 2023
Comment on lines 100 to +101
def redirect_back_or_to(url, flash_hash = {})
redirect_to(session[:return_to_url] || url, flash: flash_hash)
redirect_to(session[:return_to_url] || url, flash: flash_hash, allow_other_host: true)
Copy link
Member

Choose a reason for hiding this comment

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

The redirect_back_or_to method, unlike what's described in #318, might accept user input depending on how it's used. Therefore, it would be more secure and preferable to not set allow_other_host to true by default, but rather, to provide it as an argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants