CVE-2022-31692: Authorization rules can be bypassed via forward or include dispatcher types in Spring Security
23774
31 October 2022
31 October 2022
CLOSED
HIGH
CVE-2022-31692
Severity
High
Vendor
Spring by VMware
Description
Spring Security, versions 5.7 prior to 5.7.5 and 5.6 prior to 5.6.9 could be susceptible to authorization rules bypass via forward or include dispatcher types.Specifically, an application is vulnerable when all of the following are true:
- The application expects that Spring Security applies security to forward and include dispatcher types.
- The application uses the
AuthorizationFiltereither manually or via theauthorizeHttpRequests()method. - The application configures the
FilterChainProxyto apply to forward and/or include requests (e.g.spring.security.filter.dispatcher-types = request, error, async, forward, include). - The application may forward or include the request to a higher privilege-secured endpoint.
- The application configures Spring Security to apply to every dispatcher type via
authorizeHttpRequests().shouldFilterAllDispatcherTypes(true)
An application is not vulnerable if any of the following is true:
- The application does not use
authorizeHttpRequests()or theAuthorizationFilter. - The application does not forward/include requests.
- The application does not need to configure Spring Security to apply to FORWARD and INCLUDE dispatcher types.
Affected VMware Products and Versions
Severity is high unless otherwise noted.
- Spring Security
- 5.7.0 to 5.7.4
- 5.6.0 to 5.6.8
Mitigation
Users of affected versions should apply the following mitigations:- 5.7.x users should upgrade to 5.7.5
- 5.6.x users should upgrade to 5.6.9
- Users who cannot change versions, should use
authorizeRequests().filterSecurityInterceptorOncePerRequest(false)instead ofauthorizeHttpRequests().shouldFilterAllDispatcherTypes(true) - Users with version < 5.7.0 which does not have
shouldFilterAllDispatcherTypesavailable, should add anObjectPostProcessor:authorizeHttpRequests().withObjectPostProcessor(new ObjectPostProcessor<AuthorizationFilter>() { @Override public<O extends AuthorizationFilter> O postProcess(O filter) { filter.setObserveOncePerRequest(false); filter.setFilterAsyncDispatch(true); filter.setFilterErrorDispatch(true); return filter; }});
Note that in Spring Security 5, the default behavior is to not apply the filters more than once to a request, therefore you have to explicitly configure Spring Security to do that. In addition, the FilterChainProxy is also not configured to be invoked on forward and include dispatcher types, depending on you to do it yourself.
Releases that have fixed this issue include:
- Spring Security
- 5.7.5
- 5.6.9
Credit
This issue was identified and responsibly reported by Osword from SGLAB of Legendsec at Qi'anxin Group.
References
History
2022-10-31: Initial vulnerability report published.