What changed, and why it matters
This commit is a developer-experience (DX) improvement that adds a debug breakpoint instruction inside the firmware's Rust panic handler. When the firmware crashes, it will now halt at a breakpoint if a debugger is attached, making it easier for developers to inspect the crash. It does not change any security-sensitive behavior in normal operation and does not introduce a vulnerability.
No security action required. This is a benign debugging aid. Reviewers may optionally confirm the breakpoint does not leak sensitive data to a connected debugger beyond what the existing panic log/screen already exposes.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds cortex-m::asm::bkpt() to the #[panic_handler] in bitbox02-rust-c/src/lib.rs. The panic handler already logs the panic and, on firmware builds, prints an error screen before entering an infinite loop. The new breakpoint only triggers when a debugger is connected; otherwise it is effectively a no-op. The commit also refactors cortex-m to be a workspace dependency rather than a direct dependency in util/Cargo.toml.
Changed components
src/rust/bitbox02-rust-c/src/lib.rs panic handlerInspect captured patch +4 / −1
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index ee16e8f..cbf333c 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -32,6 +32,7 @@ resolver = "2"
# The secp-recovery feature is currently only needed in tests to make use of `RecoverableSignature`.
# Attempting to enable it conditionally only for tests somehow leads to linking errors (duplicate secp256k1 symbols).
bitcoin = { version = "0.32.7", default-features = false, features = ["secp-recovery"] }
+cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
# Forked for:
# - https://github.com/rust-bitcoin/rust-bip39/pull/76 -> custom commit can be removed once this is merged
# - async functionality
diff --git a/src/rust/bitbox02-rust-c/Cargo.toml b/src/rust/bitbox02-rust-c/Cargo.toml
index dff55b6..24d3ccc 100644
--- a/src/rust/bitbox02-rust-c/Cargo.toml
+++ b/src/rust/bitbox02-rust-c/Cargo.toml
@@ -25,6 +25,7 @@ bitbox02-rust = { path = "../bitbox02-rust", optional = true }
bitbox-aes = { path = "../bitbox-aes", optional = true }
bitbox02 = { path = "../bitbox02", optional = true }
bitbox02-noise = { path = "../bitbox02-noise", optional = true }
+cortex-m = { workspace = true }
util = { path = "../util" }
der = { version = "0.7.9", default-features = false, optional = true }
hex = { workspace = true }
diff --git a/src/rust/bitbox02-rust-c/src/lib.rs b/src/rust/bitbox02-rust-c/src/lib.rs
index e2b7bff..0030667 100644
--- a/src/rust/bitbox02-rust-c/src/lib.rs
+++ b/src/rust/bitbox02-rust-c/src/lib.rs
@@ -46,5 +46,6 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
::util::log::log!("{}", info);
#[cfg(feature = "firmware")]
bitbox02_rust::print_screen!(0, "Error: {}", info);
+ cortex_m::asm::bkpt();
loop {}
}
diff --git a/src/rust/util/Cargo.toml b/src/rust/util/Cargo.toml
index b5973d8..4441ee2 100644
--- a/src/rust/util/Cargo.toml
+++ b/src/rust/util/Cargo.toml
@@ -23,7 +23,7 @@ license = "Apache-2.0"
[dependencies]
num-bigint = { workspace = true, default-features = false }
rtt-target = { version = "0.6.1", optional = true }
-cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
+cortex-m = { workspace = true }
hex = {workspace = true}
sha2 = { workspace = true, optional = true }
p256 = { version = "0.13.2", default-features = false, features = ["arithmetic", "ecdsa"], optional = true }
Why this scored 15/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.