What changed, and why it matters
This commit closes a security gap in the BitBox02 hardware wallet's Bitcoin API. Previously, a host app could ask the device to export the 'master xpub' (the public key at the very top of the wallet, keypath m/). Combined with any leaked private key from an unhardened derivation path, that master xpub could let an attacker compute the wallet's master private key and steal all funds. The fix rejects empty keypath requests before showing any confirmation screen. The commit message itself describes the security relevance.
Ensure this fix is included in the next firmware release; verify no other API surface (e.g., legacy or multisig xpub exports) allows an empty keypath; review related keypath validation helpers for consistency.
Security signals we found
Master xpub export prevented
Private-key derivation risk described in commit message
Unhardened path key compromise scenario
Input validation added before user confirmation
Regression test for rejected root keypath
Evidence from the diff
In src/rust/bitbox02-rust/src/hww/api/bitcoin.rs, the xpub() handler now returns Error::InvalidInput immediately when keypath.is_empty(). This prevents the single-xpub API from exporting the master xpub at m/. The commit message explains the cryptographic risk: master xpub + leaked unhardened-path private key -> master private key compromise. A regression test verifies that both display=false and display=true root-keypath requests are rejected with no UI screens shown.
Changed components
BitBox02 firmware Bitcoin API xpub exportsrc/rust/bitbox02-rust/src/hww/api/bitcoin.rsInspect captured patch +16 / −0
### CHANGELOG.md
@@ -7,6 +7,7 @@ recorded separately.
## Firmware
### Unreleased
+- Reject master xpub exports at `m/` through the Bitcoin API
### v9.29.0
- Require wallet-owned refund addresses for SwapKit
### src/rust/bitbox02-rust/src/hww/api/bitcoin.rs
@@ -97,6 +97,9 @@ async fn xpub(
keypath: &[u32],
display: bool,
) -> Result<Response, Error> {
+ if keypath.is_empty() {
+ return Err(Error::InvalidInput);
+ }
let params = params::get(coin);
let is_unusual =
keypath::validate_xpub(keypath, params.bip44_coin, params.taproot_support).is_err();
@@ -611,6 +614,18 @@ mod tests {
output: Some(Output::XpubType(XPubType::Xpub as _)),
};
+ let mut root_req = req.clone();
+ root_req.keypath.clear();
+ for display in [false, true] {
+ root_req.display = display;
+ let mut mock_hal = TestingHal::new();
+ assert_eq!(
+ process_pub(&mut mock_hal, &root_req).await,
+ Err(Error::InvalidInput)
+ );
+ assert!(mock_hal.ui.screens.is_empty());
+ }
+
// -- Wrong coin: MIN-1
let mut req_invalid = req.clone();
req_invalid.coin = BtcCoin::Btc as i32 - 1;Why this scored 72/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.