Zeroization, part 1: Wiping can make things worse
Common secret-wiping patterns can add stack copies or erase memory that never held the secret.
A compiler-focused write-up argues that blindly adding secret-wiping calls can leave more copies than the original code. memset of a dead intermediate is optimized away, and the value may never have been stored in memory. Volatile byte stores can zero stack slots that never received the secret while it stays in a register, and an opaque wipe in another file can force a spill so the callee might read it. In a compare-and-wipe example built with Clang without LTO, an extra computed-tag copy remained, and the comparison ran after the wipe call.
- Compilers can delete memset of a value that is never read again.
- Volatile zero stores may miss a secret that remains in a register.
- An opaque wipe can force a new stack copy of the secret.
- That stack copy can be cleared while the register copy survives.
- Clang kept an extra tag copy and compared it after the wipe.
From the original article
7 min read at 00f.netA good hygiene when processing secrets is to wipe them after use. And projects receives countless PRs about adding calls to zeroization functions for anything that looks like a secret. This is a low-hanging fruit, something LLMs love to report, and it feels theoretically useful.
By 00f.net via olliej · 00f.net
A short excerpt; the article and its images belong to the publisher. Summary, key facts and assessment above are AI-written from the article and can be wrong.