simulator-graphical: fix factory_randomness
What changed, and why it matters
This commit fixes a simulator-only bug where the graphical BitBox02 simulator was accidentally using real device randomness instead of the fixed test value used by other simulators/test builds. The change makes the graphical simulator use the same predictable 'factory randomness' as the C unit-testing simulator. This is a test/simulator hardening fix, not a fix for the real hardware wallet firmware.
No urgent action for end users; this change only affects simulator/test builds. Developers should ensure simulator builds consistently use stubbed randomness and that production firmware remains excluded from the changed cfg guards.
Security signals we found
Use of fixed/zero 'randomness' in simulator/test code paths
Conditional compilation feature flag change
Reference to a prior similar fix for another simulator variant
No change to production firmware code paths
Evidence from the diff
The patch adds the ‘simulator-graphical’ feature to the conditional compilation guard that selects the stubbed factory_randomness() implementation returning &[0; 32]. Previously, the graphical simulator fell through to the real implementation that reads from a memory-mapped factory randomness address. The referenced prior commit (cee5bdb3ba06f60b93213f9c2a183a7683fe1551) applied the same fix to another simulator variant. The change affects only simulator/test builds and does not alter production firmware behavior.
Changed components
src/rust/bitbox02/src/hal/random.rsBitBox02 graphical simulator build (feature = simulator-graphical)Inspect captured patch +2 / −2
diff --git a/src/rust/bitbox02/src/hal/random.rs b/src/rust/bitbox02/src/hal/random.rs
index e8d976d..1ae0041 100644
--- a/src/rust/bitbox02/src/hal/random.rs
+++ b/src/rust/bitbox02/src/hal/random.rs
@@ -6,12 +6,12 @@ pub struct BitBox02Random;
impl Random for BitBox02Random {
// C simulator still uses this.
- #[cfg(feature = "c-unit-testing")]
+ #[cfg(any(feature = "c-unit-testing", feature = "simulator-graphical"))]
fn factory_randomness(&mut self) -> &'static [u8; 32] {
&[0; 32]
}
- #[cfg(not(feature = "c-unit-testing"))]
+ #[cfg(not(any(feature = "c-unit-testing", feature = "simulator-graphical")))]
#[inline(always)]
fn factory_randomness(&mut self) -> &'static [u8; 32] {
let addr =
Why this scored 33/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.