-
Notifications
You must be signed in to change notification settings - Fork 6k
HttpSessionRequestCache#getMatchingRequest passes decoded Request URL to UriComponentsBuilder #16656
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
In fact every request containing a properly encoded % sign followed by a non-hex character will cause an exception in line Line 107 in ec3cc66
spring-security/web/src/main/java/org/springframework/security/web/util/UrlUtils.java Line 85 in ec3cc66
The decoded URI could be parsed using WHAT_WG parser type but that's not configurable at that line. @marcusdacoregio can you confirm this analysis? You introduced this line in 18e8836 |
Dear Sprint Security Team, could someone please take a look at this problem? This issue is affecting us in production and we're unsure how to get around it. |
Hi @Kehrlann, do you maybe have an idea about how to solve this issue? |
Hey @ClausMie @mkleine - thanks for reaching out. I'll look into it further, but here are some obvious preliminary thoughts. You may have considered them already, but worth asking. 1. Consider removing the request cacheAre your users redirected to a default page when they log in? In case you don't need the redirect post-authentication feature, turn it off with: http
// ...
.requestCache(RequestCacheConfigurer::disable) 2. Consider setting
|
Hi @Kehrlann |
From further investigation: this appeared in Security |
- URL parsing changed in framework 6.2, and fails when path contains a % sign. - The HttpSessionRequestCache only needs to inspect the query string, not the full URL. Fixes spring-projectsgh-16656 Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
- URL parsing changed in framework 6.2, and fails when path contains a % sign. - The HttpSessionRequestCache only needs to inspect the query string, not the full URL. Fixes spring-projectsgh-16656 Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
Hi there!
Thanks for taking a look at this issue. Please let me know if you require more information.
Let's discuss!
Describe the bug
HttpSessionRequestCache#getMatchingRequest
relies onorg.springframework.web.util.UriComponentsBuilder#fromUriString(String)
to be able to handle decoded%
characters.To Reproduce
The
org.springframework.web.util.UriComponentsBuilder#fromUriString(String)
cannot handle a%
followed by characters that result in false %-encoding.This leads to a
org.springframework.web.util.InvalidUrlException: Bad path
when such a request gets tospring-security/web/src/main/java/org/springframework/security/web/savedrequest/HttpSessionRequestCache.java
Line 107 in ec3cc66
An encoded request
https://example.com/myapp/discounts/30%20%25%20off
is returned decoded byspring-security/web/src/main/java/org/springframework/security/web/util/UrlUtils.java
Lines 91 to 94 in ec3cc66
The
UriComponentsBuilder
cannot handle this decoded%
Expected behavior
My request does not result in an
InvalidUrlException
.The text was updated successfully, but these errors were encountered: