SECURITY: The SSO return_path was an open redirect

This security fix needs SSO to be configured, and the user has to go
through the entire auth process before being redirected to the wrong host so
it is probably lower priority for most installs.
This commit is contained in:
Robin Ward
2015-01-22 12:20:17 -05:00
parent e948dc88d1
commit b3a2c0c45b
2 changed files with 45 additions and 0 deletions

View File

@ -72,6 +72,17 @@ class SessionController < ApplicationController
else
log_on_user user
end
# If it's not a relative URL check the host
if return_path !~ /^\/[^\/]/
begin
uri = URI(return_path)
return_path = "/" unless uri.host == Discourse.current_hostname
rescue
return_path = "/"
end
end
redirect_to return_path
else
render text: I18n.t("sso.not_found"), status: 500