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
Deprecate trailing slash match and change default value from true to false #28552
Comments
|
I think most users would would expect that a trailing slash doesn't make a difference. From that perspective, the default is not unreasonable, and more than just HATEOAS style navigation or API guidance, even just manually typing a URL somewhere. If we change the default, many would look to change it back, so overall it's hard to avoid the need to align Spring Security with with Spring MVC through For configuring redirects, do you mean externally, like in a proxy? That would solve the problem at a different level, before Spring Security and Spring MVC, so I would be more interested in that direction but we can only make it a recommendation, and we can still make such a recommendation independent of this. |
I can see manually typing a URL as a real argument only in case of web apps (not APIs) and even there it's only potentially useful for a few select URLs that are considered to be entry points into the application and are likely to be directly entered by the users.
This is the part I strongly disagree with - what Spring Security does is nothing special nor unique. You can end up with the same kind of risks with other Java filter based security frameworks (for example, Apache Shiro) or by applying security (authorization) in an external component that sits in front of your Spring application. After all, on a high level, conceptually these all take the same approach.
Either externally in a proxy or using something like Tuckey UrlRewriteFilter or even simply using What I would like to see in Spring are the defaults that are not ambiguous and are therefore less prone to abuse. When I see a handler annotated with |
|
I'm not necessarily disagreeing. I'm merely making the point that by itself, trailing slash is not unsafe. It's only when combined with a proxy or filter that also interprets URLs, where it becomes a problem, and the problem more generally is that there may be differences, which could go both ways. That said, this is also the reason, I've come to see over time that URL paths should be left alone as is as much as possible, avoiding normalization as much as possible. It's the only way for frameworks to minimize differences and align naturally. This is also why In any case, the only way to really make a significant difference here I think is to deprecate the trailingSlash option entirely and encourage an alternative solution, like a proxy or filter to redirect. That enforces being more precise about where you want to do that exactly, and it can be done ahead of security decisions. Otherwise the possibility for a mismatch between web and security frameworks remains. It's just too easy to flip the default back and not think about it again. This is something that we'll discuss as a possibility for 6.0. |
I like that even better. Thanks for the feedback. |
|
Team decision: we'll go ahead with this. It aligns with various other path matching changes we've made in 5.2 and 5.3 such suffix pattern matching, path segment trimming, and path decoding, to make path matching more transparent and explicit. |
|
Will the default be changed to false as part of this deprecation? |
|
Yes, I'm thinking that we might as well and that we'll have to, since otherwise you'd need to set it in order to stop using it. We had the same issue with suffix pattern matching. |
|
The trailing slash option is now deprecated and set to |
|
I've just found this while browing the code @rstoyanchev : Line 85 in 50240bb
Should this value be changed as well? |
|
Looks like it, yes. |
The Spring MVC changed the default behavior for trailing slash match with spring-projects/spring-framework#28552. This causes failures in Spring Security's tests. Setting the `useTrailingSlashMatch` to `true` ensures that Spring Security will work for users who have modified the default configuration. Specifing the request mapper with trailing slash path ensures that the tests are successful when default behavior is used. Closes spring-projectsgh-11451
The Spring MVC changed the default behavior for trailing slash match with spring-projects/spring-framework#28552. This causes failures in Spring Security's tests. Setting the `useTrailingSlashMatch` to `true` ensures that Spring Security will work for users who have modified the default configuration. Specifing the request mapper with trailing slash path ensures that the tests are successful when default behavior is used. Closes gh-11451
The test started to fail when Spring Framework 6 disabled trailing slash path matching (see spring-projects/spring-framework#28552 for details). If adapted to the non-trailing version, it basically duplicates another test already present in the test class.
…ndling in Spring 6. See [0] for details. [0] spring-projects/spring-framework#28552

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

vpavic commentedJun 1, 2022
Even though this behavior has been long present in Spring, it introduces ambiguity that can (combined with some other choices) easily have consequences in shape of security vulnerabilities. Consider this example:
Default user (with role
user) will get403attempting toGET /resourcesbut can avoid protection by issuingGET /resources/, which wouldn't be possible with trailing slash matching disabled.Let me note that I'm aware that using
mvcMatchersinstead ofantMatcherswould have prevented this issue but that doesn't change the fact that there are many configurations out there relying onantMatchersand that sometimesantMatchersare simply more suitable for other reasons.Also, I personally see little real benefit of having trailing slash matching enabled because:
For places where it's really needed for application to respond to both requests, I'd argue that it's either way better solution to configure redirects instead of application wide ambiguous request mappings.
Please consider making this change for
6.0.The text was updated successfully, but these errors were encountered: