-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Content-Disposition header causes download in browser for Spring Boot Actuator endpoints [SPR-13587] #18164
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
Rossen Stoyanchev commented We can check via JAF (also via On the flip side we should be careful to double-check that a file extension is consistently recognized as such. For example |
Rob Winch commented A point of consideration is that we should check for other scripting languages like PERL, Python, etc to see if JAF / ServletContext recognizes those). |
Martin Frey commented Also happens to me after update to 4.2.2 with an ordinary controller that renders the page internally and returns it as a ResponseBody:
Is there a specific reason why |
Rossen Stoyanchev commented Martin Frey I've created a separate ticket #18207. Please follow the discussion there. |
Rossen Stoyanchev commented Here is a further update. To understand why Spring Boot Actuator endpoints need to be protected I asked Rob Winch to demonstrate RFD with an Actuator endpoint and the RFD fix suppressed. It took him very little time to find one. For example
And then
Note the point here is not to find which are vulnerable and allow the rest. The point is that it is very difficult to asses if an endpoint is vulnerable and exposed to RFD or not so simply providing an option to declare specific URLs "safe" isn't feasible. A couple of further points. Note that even today adding a "/" at the end of the URL works. In other words Yet another thought especially with the fix for #18207 is that Spring Boot Actuator endpoints may have an additional mapping added with a stable ending. For example on MetricsMvcEndpoint:
Note the additional ".json". So now I can enter /cc Andy Wilkinson, Phil Webb, Dave Syer |
Dave Syer commented That's a cute example. Doesn't it show (together with the remark that .json works) that we are in dnager of putting the cart before the horse? I really don't want or need /trace.bat to be handled by Spring MVC at all, in any shape or form - /trace is the endpoint and that's the only path I need to respond to. But IIRC I can only switch off extension mapping for the whole application, not just for a set of endpoints that I choose. That is what we should be fixing isn't it? |
Rossen Stoyanchev commented The example was fully proven out with IE from end to end. Instead of calculator an attacker could restart a person's chrome browser with CORS turned off and do countless other things. I think of that as more scary than cute. As for the suffix pattern matching, Spring Boot Actuator has its own RequestMappingHandlerMapping so you should be able to turn suffix pattern matching off there without affecting the rest of the application. |
Rossen Stoyanchev commented BTW just to be clear ".json" doesn't work as-is. You have to add an explicit mapping with ".json" in it as I showed above or some other mapping with a fixed ending. I see this is more as a way to provide safe access to such URLs in a browser, not something that should dictate REST API design (i.e. putting the horse before the cart. |
Dave Syer commented
Good point. spring-projects/spring-boot#4402 |
Dave Syer commented
This defeats the object of content negotiation being invisible to endpoints doesn't it? We don't want to explicitly map all the Actuator endpoints (and possible future or user provided ones) with all possible media types. The |
Rossen Stoyanchev commented I didn't suggest changing the existing mappings, rather to create additional ones. Let me try to explain again. MetricsMvcEndpoint and EnvironmentMvcEndpoint are mapped to My idea is that any one of these would be added as alternatives so they can be used in a browser, for example: @RequestMapping(path = {"/{name:.*}", "/{name:.*}.json"}, ...) Note also that adding a suffix "/" also works (i.e. no Content-Disposition header is added) even today. In any case I'm just raising an idea. Perhaps some sort of a consistent way of entering actuator endpoints in a browser might be one alternative to consider. |
Rossen Stoyanchev commented RFC 6266 defines two disposition types. Switching to "inline" doesn't force the download and that suits our purpose. |
Uh oh!
There was an error while loading. Please reload this page.
Rossen Stoyanchev opened SPR-13587 and commented
The fix to protect against RFD exploits (#18124) introduced a
"Content-Disposition:attachment;filename=f.txt"
response header for@ResponseBody
methods where the URL appears to have an extension that is neither whitelisted by default nor explicitly registered by the application.Spring Boot Actuator exposes many endpoints that naturally contain dots and do not represent an extension. When such a URL is typed in a browser it causes content to be downloaded as "f.txt" rather than rendered.
Several example mappings in Boot:
We need to consider ways to make the fix for RFD more flexible with this case in mind (and possible others that might yet be reported), without compromising the security of the application. For once it looks like Spring Boot metrics aren't exposed to RFD since the metric name in the URL has to match a known metric so for example appending a random extension should result in a 404.
Note this issue was originally reported under Spring Boot ticket #4220.
Affects: 4.1.8, 4.2.2
Issue Links:
@ResponseBody
methods explicitly mapped to ".html" or other extensionsReferenced from: commits 1489e29, 3a919a4, 92ca537
Backported to: 4.1.9, 3.2.16
1 votes, 7 watchers
The text was updated successfully, but these errors were encountered: