Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-22965 PoC — Spring Framework 代码注入漏洞

Source
Associated Vulnerability
Title:Spring Framework 代码注入漏洞 (CVE-2022-22965)
Description: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.
Description
Vulnerabilidad RCE en Spring Framework vía Data Binding on JDK 9+ (CVE-2022-22965 aka "Spring4Shell")
Readme
# CVE-2022-22965 aka "Spring4Shell"
> Vulnerabilidad RCE en Spring Framework vía Data Binding on JDK 9+

El objetivo es centralizar la mayor cantidad de información de público conocimiento hasta el momento de la vulnerabilidad y poder saber qué acciones tomar en tal caso.

## ¿Mi aplicación es vulnerable?

Las condiciones (AND) que se tienen que dar son:

- JDK 9 +
- Apache Tomcat como Servlet container
- Aplicación empaquetada como WAR
- Dependencia spring-webmvc o spring-webflux

## Mi aplicación está construida como un ejecutable Spring Boot jar, ¿es vulnerable?

A la fecha, no es vulnerable al exploit. Pero tener en cuenta que esta vulnerabilidad es de caracter más general por lo que pudieran existir otras formas de explotarla.

## Productos afectados

Spring Framework 
- 5.3.0 to 5.3.17
- 5.2.0 to 5.2.19

Las versiones anteriores o ya no soportadas también son afectadas.

## Mitigación

Spring Framework
- 5.3.18+
- 5.2.20+

## Otras alternativas de mitigación

En caso que no sea posible patchear la vulnerabilidad, Spring publicó algunos [workarounds](https://www.springcloud.io/post/2022-03/spring-framework-rce-early-announcement/#suggested-workarounds).

Apache Tomcat ha lanzado 3 versiones nuevas que ofrecen una protección adecuada 10.0.20, 9.0.62 y 8.5.78 y se sugiere sean consideradas como una capa de protección adicional a la actualización de Spring Framework.

## Actualizaciones adicionales

Se publicaron las versiones de Spring Boot 2.6.6 y 2.5.12 que dependen de Spring Framework 5.3.18.

## Detección

Se puede utilizar la tool https://github.com/hillu/local-spring-vuln-scanner ([mirror](https://github.com/GuayoyoCyber/CVE-2022-22965/blob/d0adebcb55fdce5b0790173a9ca21d0012d6d51b/local-spring-vuln-scanner_)) a fin de detectar instancias vulnerables a Spring4Shell. 
Un posible ejemplo de ejecución es:

`./local-spring-vuln-scanner --verbose --log </path/to/file.log> </path/to/app1> </path/to/appN>`

Hemos desarrollado una rule de deteccion para Wazuh que podras conseguir en el directorio de "detection" de este repositorio, el cual basado en una cantidad de indicadores de ataques (IOA) es posible detectar los intentos de ataques. 

## Otros CVEs y/o conceptos erróneos

- Hubo especulación acerca de un [commit](https://github.com/spring-projects/spring-framework/commit/7f7fb58dd0dae86d22268a4b59ac7c72a6c22529) en torno a la confirmación para desaprobar el uso del método SerializationUtils.deserialize(...). Esta clase no está expuesta a entradas externas y la desaprobación no está relacionada con esta vulnerabilidad.

- Hubo confusión con un CVE para **Spring Cloud Function** que se publicó justo antes del informe de esta vulnerabilidad [CVE-2022-22963](https://tanzu.vmware.com/security/cve-2022-22963#:~:text=CVE%2D2022%2D22963%3A%20Spring%20Expression%20Resource%20Access%20Vulnerability,-Severity&text=In%20Spring%20Cloud%20Function%20versions,in%20access%20to%20local%20resources.). Tampoco está relacionado.

## Laboratorio

TryHackMe ha creado un laboratorio interactivo de explotación de Spring4Shell
- https://tryhackme.com/room/spring4shell

## Referencias

- https://tanzu.vmware.com/security/cve-2022-22965
- https://app.howlermonkey.io/vulnerabilities/CVE-2022-22965
- https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement
- https://spring.io/blog/2022/04/01/spring-framework-rce-mitigation-alternative
- https://www.lunasec.io/docs/blog/spring-rce-vulnerabilities
- https://www.cyberkendra.com/2022/03/spring4shell-details-and-exploit-code.html
- https://www.praetorian.com/blog/spring-core-jdk9-rce/
- https://mp.weixin.qq.com/s/kgw-O4Hsd9r2vfme3Y2Ynw
- http://blog.o0o.nu/2010/06/cve-2010-1622.html
- https://www.microsoft.com/security/blog/2022/04/04/springshell-rce-vulnerability-guidance-for-protecting-against-and-detecting-cve-2022-22965/
- https://unit42.paloaltonetworks.com/cve-2022-22965-springshell/
File Snapshot

[4.0K] /data/pocs/7c628f8106b05c8d56bb7686ffd86ba5484051e6 ├── [4.0K] detection │   ├── [1.4M] local-spring-vuln-scanner_ │   ├── [ 694] README.md │   └── [4.0K] wazuh detection │   └── [2.5K] rule_Spring4Shell.xml ├── [4.0K] exploits │   ├── [2.9K] exploit1.py │   ├── [4.3K] exploit2.py │   └── [ 728] README.md ├── [3.8K] README.md └── [4.0K] vulnerable-app ├── [ 124] Dockerfile ├── [2.5K] pom.xml ├── [1.3K] README.md ├── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] java │   │   └── [4.0K] net │   │   └── [4.0K] javaguides │   │   └── [4.0K] springmvc │   │   └── [4.0K] helloworld │   │   ├── [4.0K] config │   │   │   ├── [ 862] AppConfig.java │   │   │   └── [ 620] SpringMvcDispatcherServletInitializer.java │   │   ├── [4.0K] controller │   │   │   └── [ 886] HelloWorldController.java │   │   └── [4.0K] model │   │   └── [ 622] HelloWorld.java │   └── [4.0K] webapp │   ├── [ 72] index.jsp │   └── [4.0K] WEB-INF │   └── [4.0K] views │   └── [ 453] helloworld.jsp └── [4.0K] target └── [6.8M] example.war 18 directories, 17 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →