Quick revision
The short answer
The heapdump endpoint was exposed over HTTP and reachable without proper authentication, usually because of management.endpoints.web.exposure.include=* with no security on Actuator. A heap dump is a copy of everything in the JVM's memory, so it contains database passwords, tokens and user data in plain form, whatever Actuator's sanitising does for other endpoints. We fix it by rotating every leaked credential, never exposing heapdump over HTTP (or only on an internal management port with strong authentication), and adding CI and platform checks that refuse such exposure settings.
What to remember
In this answer, we saw that the leak came from exposing /actuator/heapdump over HTTP without authentication, and that a heap dump holds every secret and every piece of user data in memory, untouched by Actuator's sanitising. The response is to rotate every leaked credential and check the logs, then fix the configuration in layers: an explicit exposure list, heapdump switched off, a management port inside the cluster and authentication. Guard rails in CI, the platform starter and an external scan stop the same mistake from returning.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The heapdump endpoint was exposed over HTTP and reachable without proper authentication, usually because of management.endpoints.web.exposure.include=* with no security on Actuator. A heap dump is a copy of everything in the JVM's memory, so it contains database passwords, tokens and user data in plain form, whatever Actuator's sanitising does for other endpoints. We fix it by rotating every leaked credential, never exposing heapdump over HTTP (or only on an internal management port with strong authentication), and adding CI and platform checks that refuse such exposure settings.
Why this question is asked
This finding is common in penetration tests and in real breaches, and it is serious: from one download an attacker gets the database password, API keys and often session tokens and personal data of users who were active at that moment. Interviewers ask it because the answer shows whether we understand what a heap dump really contains, how Actuator exposure and security fit together, and what a complete response looks like, not just a config change. In this answer, we will reproduce how the exposure happens, see why sanitising does not help, go through the immediate response, fix the configuration, and add guard rails so it cannot happen again.
1A Quick Recap of Actuator Exposure
Actuator endpoints have two independent switches. Access, or in older versions enabled, decides whether the endpoint exists at all. Exposure decides whether it is reachable over a given technology, HTTP or JMX. Since Spring Boot 2.5, only the health endpoint is exposed over HTTP by default, which is a safe default. Security is a third, separate layer: if Spring Security is on the classpath and configured, it decides who may call an exposed endpoint.
The heapdump endpoint, /actuator/heapdump, returns a file produced by the JVM with all objects currently in memory. It is meant for diagnosing memory leaks. For a typical service it is hundreds of megabytes, and it is served with a plain GET.
2How the Exposure Usually Happens
The pattern is nearly always the same. A developer wants to see metrics or env during development and adds a wildcard. The setting goes into the shared application.properties, not a local profile, and ships to production. The service has no Spring Security, or its security chain permits everything under /actuator because health had to be open for Kubernetes.
- exposure.include=* ships to production
- Is /actuator protected by authentication?YesRequest needs credentialsNoAnyone can call it
- GET /actuator/heapdumpJVM writes all live objects to a file
- Attacker searches the dumpstrings, heap analysers
- Finds DB password, tokens, user datain plain form
5 steps in order. Play them, or step through them one at a time.
Notice that nothing here is an exotic attack. The tester only had to try a well-known path. Scanners on the internet try /actuator/heapdump, /actuator/env and similar paths constantly, so an exposed endpoint is usually found within days.
3Why Sanitising Does Not Protect a Heap Dump
Spring Boot masks sensitive values in the env and configprops endpoints; since Boot 3.0 those values are hidden by default unless show-values is changed. Some teams assume this protects secrets everywhere. It does not, and the reason is what a heap dump is. Sanitising is a step in how the env endpoint formats its JSON response. A heap dump is not a response that Actuator formats; it is a raw copy of memory. The DataSource, the connection pool and the Environment all hold the password as a String in the heap, so it is in the dump as it is.
The same applies to everything else in memory at that moment: OAuth client secrets, signing keys, cached user profiles, HTTP request bodies being processed, session data. A heap dump should be treated with the same care as a database backup.
4The Immediate Response
Changing the configuration is not enough, because the secrets have already left. The first job is to treat it as a credential leak. We rotate every secret that the process held in memory: the database password, API keys, OAuth client secrets, signing keys and any tokens with a long lifetime. We check access logs for earlier requests to /actuator/heapdump, /actuator/env and similar paths to find out whether anyone other than the tester got there first, and we involve the security and privacy teams if user data may have been exposed, since that can trigger legal reporting duties.
Then we close the hole immediately, often with a blocking rule at the ingress or gateway for /actuator/** from outside, while the real fix rolls out.
5Fixing the Configuration
The fix has three layers, so that one mistake no longer exposes the dump. First, expose only what is needed and switch heapdump off completely in production. Second, move Actuator to a separate management port that is not routed from outside the cluster. Third, require authentication for everything except health.
When engineers genuinely need a heap dump to chase a memory leak, there are safer ways. The JVM can write one on OutOfMemoryError with -XX:+HeapDumpOnOutOfMemoryError to a protected volume, or an operator can run jcmd <pid> GC.heap_dump inside the container with audited cluster access. Both keep the file inside controlled infrastructure instead of serving it over HTTP. Note that the read-only access level is not enough here, because downloading a heap dump is a read operation.
6Guard Rails So It Cannot Happen Again
People will make this mistake again, so we add checks that catch it automatically. In CI, a simple test or a policy step scans the resolved configuration for forbidden values, such as exposure.include containing * or heapdump. In the platform starter, an EnvironmentPostProcessor can refuse to start in a production profile when those values are present, or the starter can set management.endpoints.access.max-permitted to cap what any service can enable (Boot 3.4 and later; check your version). Finally, an external scan of every public hostname for well-known actuator paths, run every day, tells us if anything slips through.
Notice that this check fails loudly at startup. A failed deploy is a far better outcome than a silently exposed heap dump.
7Follow-up questions
Would a secrets manager have prevented the leak?
Not on its own. A secrets manager keeps the password out of files and config repositories, but the application still loads it into memory to open connections, so it is still in the heap. Short-lived credentials, such as database credentials issued per hour, reduce the damage because a leaked password expires quickly.
Is the env endpoint also dangerous?
It is less dangerous since Boot 3.0, because values are hidden by default, but if someone sets show-values to always, it reveals every property including secrets. It should be protected like heapdump and its show-values setting checked by the same guard rails.
What else on Actuator deserves the same care?
threaddump can reveal request data in stack frames, loggers and other write operations change behaviour, shutdown stops the application, and configprops and env reveal configuration. Anything beyond health, info and metrics should require an operator role on an internal port.
8Conclusion
In this answer, we saw that the leak came from exposing /actuator/heapdump over HTTP without authentication, and that a heap dump holds every secret and every piece of user data in memory, untouched by Actuator's sanitising. The response is to rotate every leaked credential and check the logs, then fix the configuration in layers: an explicit exposure list, heapdump switched off, a management port inside the cluster and authentication. Guard rails in CI, the platform starter and an external scan stop the same mistake from returning.
Open with
The heapdump endpoint was exposed over HTTP and reachable without authentication. Usually someone set management.endpoints.web.exposure.include to a star and there was no security chain for Actuator, so a plain GET to /actuator/heapdump returned the whole JVM memory.
Then, if they want more
A heap dump contains every object in memory, so the DataSource password, API keys, tokens and user data are all in it as plain strings. Actuator's sanitising does not help, because that only formats the env and configprops responses; a heap dump is raw memory.
My first step is to treat it as a credential leak: rotate every secret the process held, check access logs for earlier downloads, and involve security if user data was exposed. Then I fix the configuration in layers.
I expose only an explicit list like health, info and prometheus, switch heapdump off with its access property, move Actuator to a management port that is only reachable inside the cluster, and require an operator role for everything except health. If engineers need dumps, they use HeapDumpOnOutOfMemoryError or jcmd with audited access.
Finally I add guard rails: a CI check and a platform starter check that refuse star or heapdump exposure in production, plus a daily external scan for actuator paths.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 2.5
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference, Actuator
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A penetration test downloaded a heap dump from /actuator/heapdump and found database...": https://scrivio-interview-library.netlify.app/spring-boot/actuator/4bd2cd09dc/