Skip to content

Multipart Upload with Commons Fileupload on lazy mode downloads data on cleanup [SPR-16640] #21181

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

Closed
spring-projects-issues opened this issue Mar 26, 2018 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 26, 2018

Steven Peh opened SPR-16640 and commented

Using Spring Boot v2.0.0
Apache Commons FileUpload v1.3.3

When set to resolveLazily, Spring boot will not parse the multipart request and download to local temp folder until needed. This works as expected, however if the app subsequently cancels the intent to accept the upload request, i.e. after applying authorization checks and the connection request is not authorized, during the clean up phase, Spring Boot actually initializes the multi-part to download the data so that it can cleanup.

Here's the chain of execution, all within spring boot code base:

CommonsMultipartResolver .cleanupMultipart() {
...cleanupFileItems(request.getMultiFileMap())
-> AbstractMultipartHttpServletRequest.getMultipartFiles() {
if (this.multipartFiles == null) { <-- this will be true when resolveLazily is set
initializeMultipart(); <-- here's the culprit
...
The initializeMultipart will invoke parseRequest(..) to download the multipart upload data on cleanup which doesn't make sense when we have set resolveLazily and we have rejected/cancel the request for various reasons (access control being one of them).

Its also a cyber security issue here as unauthorized requests can upload arbitrary data, though only temporarily it can still be a very large file that use up storage, to the server.


Affects: 4.3.14, 5.0.4

Issue Links:

Referenced from: commits 10cb2cc, c1cb031

Backported to: 4.3.15

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We explicitly check whether the multipart request has been resolved at all now, in CommonsMultipartResolver as well as StandardServletMultipartResolver, before trying to perform a cleanup.

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants