What changed, and why it matters
This commit fixes a crash in the software simulator used for testing the BitBox02 hardware wallet. The simulator was trying to read a special memory address that only exists on the physical device, causing it to crash. The fix makes the simulator return a placeholder value of all zeros instead. This only affects test tooling, not real devices or user funds.
No security action required. This is a test-infrastructure bug fix. Reviewers may want to confirm that the `c-unit-testing` feature is never enabled in production or release firmware builds.
Security signals we found
Memory access violation (segfault) in simulator environment
Conditional compilation used to separate simulator and device behavior
No cryptographic weakness introduced: simulator uses deterministic placeholder randomness, which is appropriate for testing
Evidence from the diff
The commit adds a conditional implementation of the factory_randomness() method in BitBox02Random for the c-unit-testing feature (used by the C simulator). Previously, the simulator used the same implementation as the real device, which dereferenced a device-specific static memory address and caused a segfault. The fix provides a simulator-safe implementation returning a static [0; 32] array, while the real-device implementation remains gated behind #[cfg(not(feature = "c-unit-testing"))].
Changed components
src/rust/bitbox02/src/hal/random.rsC simulator build (c-unit-testing feature)BitBox02Random HAL implementationInspect captured patch +7 / −0
diff --git a/src/rust/bitbox02/src/hal/random.rs b/src/rust/bitbox02/src/hal/random.rs
index 9921543..e8d976d 100644
--- a/src/rust/bitbox02/src/hal/random.rs
+++ b/src/rust/bitbox02/src/hal/random.rs
@@ -5,6 +5,13 @@ use bitbox_hal::Random;
pub struct BitBox02Random;
impl Random for BitBox02Random {
+ // C simulator still uses this.
+ #[cfg(feature = "c-unit-testing")]
+ fn factory_randomness(&mut self) -> &'static [u8; 32] {
+ &[0; 32]
+ }
+
+ #[cfg(not(feature = "c-unit-testing"))]
#[inline(always)]
fn factory_randomness(&mut self) -> &'static [u8; 32] {
let addr =
Why this scored 18/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.