Skip to content

Multipartfile request with no authentication is still consumed even after an AccessDeniedException is thrown #7060

Closed
@a-sayyed

Description

@a-sayyed

Summary

As explained by @wilkinsona in this related issue: spring-projects/spring-boot#17345, a multipartfile request with no authentication to a secure endpoint, results in an AccessDeniedException (when the HiddenHttpMethodFilter is disabled). This is handled in ExceptionTranslationFilter.handleSpringSecurityException(HttpServletRequest, HttpServletResponse, FilterChain, RuntimeException) which results in the creation of a DefaultSavedRequest. This calls javax.servlet.ServletRequest.getParameterMap() which causes the multipart request to be consumed and parsed.

Actual Behavior

Multipart file request with no Authentication to a secure endpoint results in the request being parsed and consumed anyway, then the client gets a 401 Unauthorized

Expected Behavior

Multipart file request with no Authentication to a secure endpoint should result in the request not being parsed or consumed, and the client gets a 401 Unauthorized as soon as an AccessDeniedException is thrown.

Configuration

Please see the attached sample. You will need to add the property spring.mvc.hiddenmethod.filter.enabled=false to the application.properties file

Version

2.1.6.RELEASE

Sample

https://github.com/a-sayyed/spring-jetty-secure-multipartfile-upload-bug
2019-06-28_09h29_33

Metadata

Metadata

Assignees

Labels

in: webAn issue in web modules (web, webmvc)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions