-
Notifications
You must be signed in to change notification settings - Fork 41k
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
Disable by default suffix pattern matching in Spring MVC #11105
Comments
/cc @rstoyanchev @rwinch for opinions on this. Is changing from the MVC default a good idea? |
TL;DR: this issue is about flipping the default for |
We don't like the default in Spring MVC to begin with. This is the current advice we give but we can't change it without causing at least as much pain. Note that there are two aspects to this issue. One is suffix pattern matching (i.e. "/foo" also implies "/foo.*") and that can be turned off via Turning off suffix pattern matching and content type resolution by file extension in favor of using a query parameter (if needed) is the ideal place to be. The explicit registration of known extensions may be a good middle ground that significantly limits the feature while also minimizing the impact to existing applications. One idea for a list of extensions is to see what was done as part of a broader fix for RFD attacks in AbstractMessageConverterMethodProcessor, look for For what it's worth on the WebFlux side we do not support mapping by file extension. Neither do we support content type negotiation by file extension. By default only |
To add to what Rossen stated. Allowing for suffix pattern matching and matrix variables has been a large source of security bypass vulnerabilities. I would love to see path matching be less complicated to reduce the possibility of vulnerabilities in applications. |
It's very tempting to change our default in 2.0 and offer a quick property to flip things back. I know it could cause upgrade pain, but it also:
|
I'd like to flip that default as well. We should do that as soon as possible, because this might impact a lot of applications/clients relying on that behavior. By our own standards, changing that after the milestone phase is the very last opportunity to do that. |
I believe this change has made WebMvcConfigurer.configureContentNegotiation(ContentNegotiationConfigurer configurer) ineffective, regardless of the @order value given, as WebMvcAutoConfiguration.configureContentNegotiation(ContentNegotiationConfigurer configurer) always seems to happen after the user configurer. This means the only way to configure the content negotiation is through the property files. In 1.5, I was calling configurer.favorParameter(true), but this gets overwritten by the default property, false. |
Hi @dpash, I've reproduced this and it seems to be a much broader issue about the ordering of Spring Boot's |
The behaviour before Spring Boot 2.0 has some weird behaviour in particular scenarios. I have a file like this Btw, it seems that whenever a request is made, the registered paths are iterated to find the matching one. Shouldn't they be cached somehow, in case a path has been matched for a request the next time a similar request is made the method mapping should not be recalculated? |
no clear documents, changing fast. The spring security and suffix things waste a lot of people time, totally stupid, nutty! |
For those looking for documentation, the migration guide should help. |
This fix really killed my application and i had no idea where to look for the fix because there was no appropiate error warning. Please consider my story: Even though i think it is usefull to have an auto-configuration like this, it breaks existing applications with no reason and feels like an anti-pattern. I'd suggest a bug here that the |
@getJack Sorry that you have to deal with this situation. I've got a few questions for you, so we can hopefully resolve that situation - could you answer those?
|
Hi @bclozel , Regarding 2): Not sure if there was ever a check for domains like ".co.uk" . Just inherited the project from a co-worker. |
@getJack there must be something else at play here, because this mapping still properly works in a Spring Boot 2.0 application. Do you have a sample application I can take a look at? |
I know what went wrong here. There was an empty annotated class using |
See this twitter exchange. We should confirm the existing behavior and consider it again for 2.0.
The text was updated successfully, but these errors were encountered: