-
Notifications
You must be signed in to change notification settings - Fork 6k
DefaultRedirectStrategy vulnerable to open redirect phishing attacks using protocol relative paths (double slash) #4197
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
Comments
Wouldn't this fix solve this problem too ? |
Hi @mpalourdio - thanks for responding quickly. The issue is worded from the perspective of it being done by mistake rather than for phishing, and leans to tolerance. However, as a redirect class from a security library, I think it should lean to caution, and assume that people setting contextRelative are focused on security enforcement rather than URL preference. |
I agree that the default behaviour in this library should be very defensive in most cases. Maybe @rwinch can give a feedback on those 2 issues. I must say that at first sight, the default behavior of That's why too I wouldn't see a problem to throw an exception in the case of #4142 |
I appreciate this is quite old, but it remains open and I wanted to comment on our recent pen test findings. the calculateRedirectUrl method strips out the scheme and then looks for the contextPath. This presents a vulnerability that can be exploited by attackers added more '/' characters in front of their url. For example the following would all correctly keep you within the main application after running through this method
For the time being we are cleaning the url before it goes through to the calculateRedirectUrl method, by not allowing more than 1 consecutive '/'character, but I think this should be part of this security method. To add further complexity this can be exploited by adding more '/' characters in the middle of the redirect url. For example |
Summary
If a org.springframework.security.web.DefaultRedirectStrategy is configured to be context relative, it does not prevent against protocol relative URLs. The configuration would suggest protection against phishing attacks, but this is not the case if it can take you to another domain.
This was mentioned here with a suggested solution by Wojciech Gizynski. If worried as to the suggestion, protection against only use cases that start with // might be lower risk:
#2405 (comment)
Actual Behavior
A query parameter such as
?redirect=//phishing.com
will redirect you to another domain despite the strategy being configured as context relative.Expected Behavior
A query parameter such as
?redirect=//phishing.com
will redirect you to a context relative location if the strategy has been configured as context relative.Configuration
Version
4.2.1.RELEASE
The text was updated successfully, but these errors were encountered: