From 217dbe8f9ee467ab0b5831d8bf18625c46c690e9 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Wed, 23 Sep 2026 03:29:14 +0200 Subject: [PATCH] F-11039: zeroize XFREE'd slots in the static malloc pool The small-stack crypto pool hands out workspace for hash blocks and signature verification state; the slot was released back to the pool still holding that data. Scrub it in XFREE before marking the slot free (wc_ForceZero, same helper the rest of the crypto path uses). --- src/xmalloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xmalloc.c b/src/xmalloc.c index a270c2ff..46930e8b 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -26,6 +26,7 @@ #include #include #include +#include /* wc_ForceZero */ #ifndef USE_FAST_MATH #include #include @@ -514,6 +515,9 @@ void XFREE(void *ptr, void *heap, int type) #endif while (xmalloc_pool[i].addr) { if ((ptr == (void *)(xmalloc_pool[i].addr)) && xmalloc_pool[i].in_use) { + /* Scrub the slot before releasing it: it may hold crypto + * workspace (hash blocks, signature verification state). */ + wc_ForceZero(xmalloc_pool[i].addr, xmalloc_pool[i].size); xmalloc_pool[i].in_use = 0; return; }