Companion repository for the ankurm.com article. Every transcript in docs/output/ was produced by running this project; scripts/run-all.sh regenerates all of them. Verified against Spring Boot 4.1.1 / Framework 7.0.9 / Security 7.1.1 / Micrometer 1.17.1 / kafka-clients 4.2.1 on Temurin JDK 25.0.4.1+1.
24 lines
1.2 KiB
Bash
Executable File
24 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The endpoint that really does hand over your secrets - once you turn it on.
|
|
set -uo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
OUT=docs/output/04-heapdump-leak.txt
|
|
B=http://localhost:8080/actuator
|
|
{
|
|
echo "### profiles: exposeall,open PLUS --management.endpoint.heapdump.access=unrestricted"
|
|
echo
|
|
echo "\$ curl -s -o /tmp/heap.hprof -w 'status=%{http_code} bytes=%{size_download} type=%{content_type}' $B/heapdump"
|
|
curl -s -o /tmp/heap.hprof -w 'status=%{http_code} bytes=%{size_download} type=%{content_type}\n' "$B/heapdump"
|
|
echo
|
|
echo "\$ strings /tmp/heap.hprof | grep -c 'S3CRET-partner-credential'"
|
|
strings /tmp/heap.hprof 2>/dev/null | grep -c 'S3CRET-partner-credential'
|
|
echo "\$ strings /tmp/heap.hprof | grep -o 'not-a-real-password[^\"]*' | head -1"
|
|
strings /tmp/heap.hprof 2>/dev/null | grep -o 'not-a-real-password[^\"]*' | head -1
|
|
echo
|
|
echo " /actuator/env masked both of these to ******."
|
|
echo " /actuator/heapdump handed over the process memory that contains them in plaintext."
|
|
echo " Sanitisation is a property-rendering feature. It is not a security boundary."
|
|
rm -f /tmp/heap.hprof
|
|
} > "$OUT" 2>&1
|
|
echo "wrote $OUT"
|