Video in progress
What secrets does a prod heap dump contain, and what rules do you follow when working with one?
A heap dump is a full copy of the process memory: passwords, JWT tokens, API keys, DB connection strings, users' personal data and card numbers can all be in plain text. So I protect it like a copy of the prod database: restricted access, encrypted storage, short retention.
📖 Answer
One simple experiment will change your mind: take a dump from any Spring Boot service and search it in MAT with OQL:
SELECT s.toString() FROM java.lang.String s WHERE s.toString() LIKE ".*password.*"
The DataSource configuration, Authorization: Bearer ... headers, request bodies, customer objects in the cache: it is all in there. Even keeping a password in a char[] helps little if it hasn't been cleared yet.
The rules I follow:
- Where it is written.
-XX:HeapDumpPathonly to an encrypted volume that only the application user can read. Not the shared/tmp. - Moving it. Not to a laptop, but to an analysis machine with restricted access or to a bucket (encrypted, with an access log). Never attach it to Slack or a ticket.
- Retention. Delete it when the analysis is done, with an automatic TTL (for example, 7 days).
- Who sees it. Only people who have access to prod data. Giving it to an outside vendor is a separate agreement.
- Not taking one when you don't need to. For many questions a class histogram or JFR is enough, and they don't contain the content of the objects.
There are also utilities that "sanitize" a dump: they replace the contents of primitive arrays and strings with zeros. For hunting a leak this is often enough, because you need the object counts and references, not the content.
One more thing: JFR recordings can also contain environment variables and system properties. Store them with the same care.
Sign up to mark studied questions and save your progress.