Skip to content

Commit

Permalink
Fixes #36768: Prevent redirection to other hosts via HTTP referer header
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms authored and evgeni committed Sep 26, 2023
1 parent d0fcacd commit 2517ba4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def process_ajax_error(exception, action = nil)
end

def redirect_back_or_to(url)
redirect_back(fallback_location: url)
redirect_back(fallback_location: url, allow_other_host: false)
end

def saved_redirect_url_or(default)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class UsersControllerTest < ActionController::TestCase

context "when user is logged in" do
test "#login redirects to previous url" do
@previous_url = "/bookmarks"
@previous_url = "http://test.host/bookmarks"
get :login, session: set_session_user
request.env['HTTP_REFERER'] = @previous_url

Expand Down

0 comments on commit 2517ba4

Please sign in to comment.