CVE-2022-22965
Remote Code Execution in Spring Framework
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-webmvcorspring-webfluxdependency
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).
Affected Maven artifacts (5)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.springframework » spring-beans | < 5.2.20.RELEASE>= 5.3.0, < 5.3.18 | 5.2.20.RELEASE, 5.3.18 |
| org.springframework » spring-webflux | < 5.2.20.RELEASE>= 5.3.0, < 5.3.18 | 5.2.20.RELEASE, 5.3.18 |
| org.springframework » spring-webmvc | < 5.2.20.RELEASE>= 5.3.0, < 5.3.18 | 5.2.20.RELEASE, 5.3.18 |
| org.springframework.boot » spring-boot-starter-web | < 2.5.12>= 2.6.0, < 2.6.6 | 2.5.12, 2.6.6 |
| org.springframework.boot » spring-boot-starter-webflux | < 2.5.12>= 2.6.0, < 2.6.6 | 2.5.12, 2.6.6 |
Blast radius
100% of the dependent artifacts (76,310) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 551,222 |
| 2 hops | 1,292,659 |
| 3 hops | 1,570,609 |
| 4 hops | 809,048 |
| 5 hops | 283,334 |
| 6 hops | 116,010 |
Most used dependents
- org.springframework.boot » spring-boot-starter-test20,993 usages
- org.springframework.boot » spring-boot-starter-web19,081 usages
- org.springframework » spring-context18,670 usages
- org.springframework.boot » spring-boot-autoconfigure15,709 usages
- org.springframework.boot » spring-boot-starter12,901 usages
- org.springframework » spring-test12,234 usages
- org.springframework » spring-web12,086 usages
- org.springframework » spring-webmvc7,538 usages
- org.springframework.boot » spring-boot-starter-actuator6,564 usages
- org.springframework » spring-jdbc5,611 usages
- org.springframework.boot » spring-boot5,107 usages
- org.springframework » spring-tx5,095 usages
- org.springframework.boot » spring-boot-starter-validation4,721 usages
- org.springframework.boot » spring-boot-starter-aop4,662 usages
- org.springframework » spring-context-support4,340 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
- Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2022-22965
- Webhttps://github.com/spring-projects/spring-framework/commit/002546b3e4b8d791ea6acccb81eb3168f51abb15
- Webhttps://cert-portal.siemens.com/productcert/pdf/ssa-254054.pdf
- Webhttps://github.com/spring-projects/spring-boot/releases/tag/v2.5.12
- Webhttps://github.com/spring-projects/spring-boot/releases/tag/v2.6.6
- Packagehttps://github.com/spring-projects/spring-framework
- Webhttps://github.com/spring-projects/spring-framework/releases/tag/v5.2.20.RELEASE
- Webhttps://github.com/spring-projects/spring-framework/releases/tag/v5.3.18
- Webhttps://psirt.global.sonicwall.com/vuln-detail/SNWLID-2022-0005
- Webhttps://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
- Webhttps://tanzu.vmware.com/security/cve-2022-22965
- Webhttps://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-java-spring-rce-Zx9GUc67
- Webhttps://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2022-22965
- Webhttps://www.kb.cert.org/vuls/id/970766
- Webhttps://www.oracle.com/security-alerts/cpuapr2022.html
- Webhttps://www.oracle.com/security-alerts/cpujul2022.html
- Webhttp://packetstormsecurity.com/files/166713/Spring4Shell-Code-Execution.html
- Webhttp://packetstormsecurity.com/files/167011/Spring4Shell-Spring-Framework-Class-Property-Remote-Code-Execution.html
