Encrypted, and still in the logs
Secrets were encrypted at rest and in transit, and still turned up in logs, build artifacts and memory. Where secrets leak, and what we changed.
Written
The situation
Everything was encrypted. Secrets sat in a secrets manager, encrypted at rest. They travelled over TLS, encrypted in transit. Access was logged and audited. The algorithms were strong and the setup was correct.
The secrets still leaked. They turned up in logs, build artifacts, memory dumps and debugging output. No cipher was broken. The secrets flowed through systems that had every right to read them.
What was wrong
The team believed encryption settled the question. Encrypted at rest, encrypted in transit, access controlled: done. The rest was operational detail.
Encryption protects a secret until it is decrypted. A secret has to be decrypted to be used, and that is where the exposure began.
- Secrets were decrypted too early. Applications fetched them at startup and held them in memory for their whole life. Memory is visible to debuggers, crash dumps and process inspection.
- Secrets flowed through logs. Applications logged their configuration for debugging. Pipelines printed environment variables for troubleshooting. Deploy scripts logged connection strings to verify them. Logs are retained, searchable, and read by more people than you think.
- Secrets sat in build artifacts. Pipelines injected them as environment variables at build time. From there they landed in build logs, Docker layer history and container metadata. Artifacts are stored, shared, and sometimes public.
- Too many systems could read them. Pipelines needed secrets to deploy, monitoring needed them to connect, debugging tools needed them to troubleshoot. Each system with read access was a path for a leak.
- Convenience widened the blast radius. Secrets were decrypted once and shared across services, cached for speed, replicated for redundancy. Each shortcut made operations easier and added a place where the secret sat in plain text.
None of this was negligence. The systems worked as designed and the workflows were normal. The leakage was built in.
What changed
We started to treat secrets as live data that flows through systems. Storing them safely was the smaller part. The questions that matter are where a secret is decrypted, when, and who can reach it there. The algorithm comes a long way behind. AES-256 in a log file is less safe than weaker encryption nobody ever decrypts in the open.
If a system can read a secret, it can leak it. So the fix was less fan-out, and more encryption would have done nothing. Fewer systems with access, fewer decryption points, a shorter window. Decrypt as late as possible, hold it as briefly as possible, destroy it as soon as possible. Every convenience that widens that window is a cost, and the costs compound.