Skip to content

Remote Code Execution in Spring Framework

Critical severity GitHub Reviewed Published Mar 31, 2022 to the GitHub Advisory Database • Updated Jan 31, 2023

Package

maven org.springframework.boot:spring-boot-starter-web (Maven)

Affected versions

< 2.5.12
>= 2.6.0, < 2.6.6

Patched versions

2.5.12
2.6.6
maven org.springframework.boot:spring-boot-starter-webflux (Maven)
< 2.5.12
>= 2.6.0, < 2.6.6
2.5.12
2.6.6
maven org.springframework:spring-beans (Maven)
>= 5.3.0, < 5.3.18
< 5.2.20.RELEASE
5.3.18
5.2.20.RELEASE
maven org.springframework:spring-webflux (Maven)
>= 5.3.0, < 5.3.18
< 5.2.20.RELEASE
5.3.18
5.2.20.RELEASE
maven org.springframework:spring-webmvc (Maven)
>= 5.3.0, < 5.3.18
< 5.2.20.RELEASE
5.3.18
5.2.20.RELEASE

Description

Spring Framework prior to versions 5.2.20 and 5.3.18 contains a remote code execution vulnerability known as Spring4Shell.

Impact

A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires the application to run on Tomcat as a WAR deployment. If the application is deployed as a Spring Boot executable jar, i.e. the default, it is not vulnerable to the exploit. However, the nature of the vulnerability is more general, and there may be other ways to exploit it.

These are the prerequisites for the exploit:

  • JDK 9 or higher
  • Apache Tomcat as the Servlet container
  • Packaged as WAR
  • spring-webmvc or spring-webflux dependency

Patches

Workarounds

For those who are unable to upgrade, leaked reports recommend setting disallowedFields on WebDataBinder through an @ControllerAdvice. This works generally, but as a centrally applied workaround fix, may leave some loopholes, in particular if a controller sets disallowedFields locally through its own @InitBinder method, which overrides the global setting.

To apply the workaround in a more fail-safe way, applications could extend RequestMappingHandlerAdapter to update the WebDataBinder at the end after all other initialization. In order to do that, a Spring Boot application can declare a WebMvcRegistrations bean (Spring MVC) or a WebFluxRegistrations bean (Spring WebFlux).

References

Published to the GitHub Advisory Database Mar 31, 2022
Reviewed Mar 31, 2022
Published by the National Vulnerability Database Apr 1, 2022
Last updated Jan 31, 2023

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

EPSS score

97.433%
(100th percentile)

CVE ID

CVE-2022-22965

GHSA ID

GHSA-36p3-wjmg-h94x

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.