# CVE-2022-22965: Remote Code Execution in Spring Framework

> CVE-2022-22965 (GitHub advisory GHSA-36p3-wjmg-h94x) is a critical-severity vulnerability with a CVSS 3.1 base score of 9.8, classed as Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (CWE-74), in 5 packages, including org.springframework:spring-beans (Maven) and org.springframework:spring-webmvc (Maven). Fixed versions: org.springframework:spring-beans 5.2.20.RELEASE or 5.3.18; org.springframework:spring-webmvc 5.2.20.RELEASE or 5.3.18; and 3 more packages. CISA lists it as a known exploited vulnerability (added 4 Apr 2022).

Canonical page: https://cveminer.com/vulnerabilities/CVE-2022-22965

| Field | Value |
| --- | --- |
| CVE | CVE-2022-22965 |
| GHSA | GHSA-36p3-wjmg-h94x |
| Severity | Critical |
| CVSS 3.1 | 9.8 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:H` (GitHub Advisory Database) |
| CVSS 3.1 | 9.8 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H` (CVE.org) |
| CWE | CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'); CWE-94 Improper Control of Generation of Code ('Code Injection') |
| EPSS | 99.63% (higher than 99.9% of CVEs) |
| CISA KEV | Listed 4 Apr 2022, due 25 Apr 2022 |
| SSVC | exploitation active, automatable yes, technical impact total |
| Published | 31 Mar 2022 |
| Modified | 22 Oct 2025 |

## 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

- Spring Framework [5.3.18](https://github.com/spring-projects/spring-framework/releases/tag/v5.3.18) and [5.2.20](https://github.com/spring-projects/spring-framework/releases/tag/v5.2.20.RELEASE)
- Spring Boot [2.6.6](https://github.com/spring-projects/spring-boot/releases/tag/v2.6.6) and [2.5.12](https://github.com/spring-projects/spring-boot/releases/tag/v2.5.12)

#### 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 packages

| Package | Ecosystem | PURL | Vulnerable versions | Fixed in |
| --- | --- | --- | --- | --- |
| org.springframework:spring-beans | Maven | `pkg:maven/org.springframework/spring-beans` | >= 5.3.0, < 5.3.18; < 5.2.20.RELEASE | 5.2.20.RELEASE, 5.3.18 |
| org.springframework:spring-webmvc | Maven | `pkg:maven/org.springframework/spring-webmvc` | >= 5.3.0, < 5.3.18; < 5.2.20.RELEASE | 5.2.20.RELEASE, 5.3.18 |
| org.springframework.boot:spring-boot-starter-web | Maven | `pkg:maven/org.springframework.boot/spring-boot-starter-web` | < 2.5.12; >= 2.6.0, < 2.6.6 | 2.5.12, 2.6.6 |
| org.springframework:spring-webflux | Maven | `pkg:maven/org.springframework/spring-webflux` | >= 5.3.0, < 5.3.18; < 5.2.20.RELEASE | 5.2.20.RELEASE, 5.3.18 |
| org.springframework.boot:spring-boot-starter-webflux | Maven | `pkg:maven/org.springframework.boot/spring-boot-starter-webflux` | < 2.5.12; >= 2.6.0, < 2.6.6 | 2.5.12, 2.6.6 |

## Fix commits

- Patch: https://github.com/spring-projects/spring-framework/commit/002546b3e4b8d791ea6acccb81eb3168f51abb15
- Release: https://github.com/spring-projects/spring-framework/commit/cfa701b8726f06528e9d408b1b94f333f70da45f (5.2.20)
- Release: https://github.com/spring-projects/spring-framework/commit/707a24c48b21fc35e8be715afc80f020a24a9714 (5.3.18)

## Questions

**What is the GHSA ID for CVE-2022-22965?**

GitHub tracks CVE-2022-22965 as GHSA-36p3-wjmg-h94x.

**What is the CVSS score of CVE-2022-22965?**

CVE-2022-22965 has a CVSS 3.1 base score of 9.8 (Critical), vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:H.

**Which versions are affected by CVE-2022-22965?**

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

**How do I fix CVE-2022-22965?**

Upgrade each package to its fixed version: org.springframework:spring-beans 5.2.20.RELEASE or 5.3.18; org.springframework:spring-webmvc 5.2.20.RELEASE or 5.3.18; org.springframework.boot:spring-boot-starter-web 2.5.12 or 2.6.6; org.springframework:spring-webflux 5.2.20.RELEASE or 5.3.18; and 1 more packages. The fix is in commit 002546b.

**What is the Package URL (PURL) for CVE-2022-22965?**

The affected packages' PURLs are pkg:maven/org.springframework/spring-beans, pkg:maven/org.springframework/spring-webmvc, pkg:maven/org.springframework.boot/spring-boot-starter-web, pkg:maven/org.springframework/spring-webflux and pkg:maven/org.springframework.boot/spring-boot-starter-webflux.

**Is CVE-2022-22965 exploited in the wild?**

CISA lists it as a known exploited vulnerability (added 4 Apr 2022). CISA's SSVC assessment rates exploitation as "active". EPSS estimates a 99.63% chance of exploitation in the next 30 days, higher than 99.9% of CVEs.

## References

- https://github.com/spring-projects/spring-framework/commit/002546b3e4b8d791ea6acccb81eb3168f51abb15 (fix)
- https://nvd.nist.gov/vuln/detail/CVE-2022-22965 (advisory)
- https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-java-spring-rce-Zx9GUc67 (advisory)
- https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/22xxx/CVE-2022-22965.json (advisory)
- https://github.com/advisories/GHSA-36p3-wjmg-h94x (advisory)
- https://github.com/spring-projects/spring-framework (package)
- https://cert-portal.siemens.com/productcert/pdf/ssa-254054.pdf
- https://github.com/spring-projects/spring-boot/releases/tag/v2.5.12
- https://github.com/spring-projects/spring-boot/releases/tag/v2.6.6
- https://github.com/spring-projects/spring-framework/releases/tag/v5.2.20.RELEASE
- https://github.com/spring-projects/spring-framework/releases/tag/v5.3.18
- https://psirt.global.sonicwall.com/vuln-detail/SNWLID-2022-0005
- https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
- https://tanzu.vmware.com/security/cve-2022-22965
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2022-22965
- https://www.kb.cert.org/vuls/id/970766
- https://www.oracle.com/security-alerts/cpuapr2022.html
- https://www.oracle.com/security-alerts/cpujul2022.html
- http://packetstormsecurity.com/files/166713/Spring4Shell-Code-Execution.html
- http://packetstormsecurity.com/files/167011/Spring4Shell-Spring-Framework-Class-Property-Remote-Code-Execution.html

---

Source: CVEminer (https://cveminer.com/vulnerabilities/CVE-2022-22965), compiled from OSV (GitHub advisory), GitHub Advisory Database, OSV (CVE record), CVE.org, CISA KEV catalog. OSV and GitHub Advisory Database content is licensed CC BY 4.0.
