Prevent memory_reset_hww from masking flash write failures
What changed, and why it matters
This commit fixes a bug in how the BitBox02 hardware wallet reports whether it successfully erased and rewrote sensitive memory during a factory reset-style operation. Previously, if the first flash write failed but a later write succeeded, the function could incorrectly report overall success, potentially leaving old wallet data partially intact without the user or device realizing it. The fix checks each write separately and stops reporting success if any write fails.
Treat this as a security-relevant bug fix. Verify whether memory_reset_hww() is reachable during device reset, factory reset, or firmware update flows. Review the full function to confirm the CHUNK_1 write result is also checked individually as described. Consider whether a CVE is warranted given the hardware-wallet context and potential for incomplete wipe.
Security signals we found
Failure-masking bug in security-critical reset function
Flash write success/failure not propagated correctly
Potential incomplete wipe of hardware wallet memory
Function returning success despite earlier write failure
Evidence from the diff
memory_reset_hww() in src/memory/memory.c previously combined the results of multiple flash writes using bitwise OR (|=). Because a later successful write would set res to true, an earlier failed write could be masked. The patch changes the shared-data write to use logical AND with the prior result (res = _write_to_address(…) && res), so any single failure causes the function to return false. The CHUNK_1 write path is not shown in the diff but the commit message states both writes are now checked individually. This is a correctness fix in a security-critical reset path.
Changed components
src/memory/memory.cmemory_reset_hww()Flash memory write path for HWW and shared BLE dataInspect captured patch +1 / −2
diff --git a/src/memory/memory.c b/src/memory/memory.c
index e1e173f..f960f83 100644
--- a/src/memory/memory.c
+++ b/src/memory/memory.c
@@ -371,7 +371,6 @@ bool memory_reset_hww(void)
}
// Initialize hww memory
-
chunk_1_t chunk = {0};
CLEANUP_CHUNK(chunk);
_read_chunk(CHUNK_1, chunk_bytes);
@@ -405,7 +404,7 @@ bool memory_reset_hww(void)
chunk_shared.fields.ble_identity_address[0] |= 0xc;
memset(&chunk_shared.fields.ble_bond_db, 0xff, sizeof(chunk_shared.fields.ble_bond_db));
- res |= _write_to_address(FLASH_SHARED_DATA_START, 0, chunk_shared.bytes);
+ res = _write_to_address(FLASH_SHARED_DATA_START, 0, chunk_shared.bytes) && res;
}
return res;
Why this scored 61/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.