libjade: clear keychain on libjade_stop()
What changed, and why it matters
This change makes the Jade hardware wallet library wipe sensitive key material from memory when the library is stopped. Previously, stopping the library may have left private keys or seed data sitting in memory, which could be read by other software or later code running on the same device. The fix adds a single cleanup call when libjade_stop() runs.
Treat as a security hardening fix and include in the next release. Review whether other teardown paths (error exits, reset paths) also call keychain_clear(). Consider whether keychain_clear() itself securely zeroes memory and is not optimized away by the compiler.
Security signals we found
Sensitive memory not cleared on teardown
Key material potentially left resident after library stop
Defensive secret-zeroing patch
Evidence from the diff
The commit adds a keychain_clear() call inside libjade_stop() in libjade/libjade.c. The function already destroyed serial and ring-buffer resources, but did not clear the keychain. Without this call, cryptographic keys/secrets held in the keychain structure could remain in memory after the library teardown, increasing the risk of information disclosure via memory scraping, reuse, or side-channel access. The patch is minimal and defensive.
Changed components
libjade/libjade.clibjade_stop()keychainInspect captured patch +2 / −0
diff --git a/libjade/libjade.c b/libjade/libjade.c
index b67b063..267ad94 100644
--- a/libjade/libjade.c
+++ b/libjade/libjade.c
@@ -469,6 +469,8 @@ void libjade_stop(void)
serial_out = NULL;
vRingbufferDelete(internal_out);
internal_out = NULL;
+ // clear keychain
+ keychain_clear();
}
static uint8_t _libjade_serial_data_in[MAX_INPUT_MSG_SIZE + 1] = { 0 };
Why this scored 58/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.