Skip to content

Commit ebbae86

Browse files
committed
bitcoin: allow spending UTXOs at very high address indices
In a BIP-44 keypath `m/purpose/coin/account/{0,1}/addressIdx`, we disallow addressIdx >= 10000 when verifying receive addresses to mitigate ransom attacks (attacker as victim verify an address at a very high index, so the victim cannot find the funds). The same check is applied to change outputs in transactions for the same reason. We also had the same check for inputs in the transaction, but there, the check is not necessary. We want to be able to spend UTXOs that were received on high indices.
1 parent 897e9d3 commit ebbae86

File tree

4 files changed

+235
-156
lines changed

4 files changed

+235
-156
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
99
### [Unreleased]
1010
- Bitcoin: add support for payment requests
1111
- Bitcoin: allow multisig accounts at arbitrary keypaths
12+
- Bitcoin: allow spendung UTXOs at very high BIP-44 address indices
1213
- Ethereum: allow signing EIP-712 messages containing multi-line strings
1314

1415
### 9.18.0

src/rust/bitbox02-rust/src/hww/api/bitcoin.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub fn derive_address_simple(
155155
coin_params.bip44_coin,
156156
simple_type,
157157
coin_params.taproot_support,
158+
keypath::ReceiveSpend::Receive,
158159
)
159160
.or(Err(Error::InvalidInput))?;
160161
Ok(common::Payload::from_simple(
@@ -194,7 +195,8 @@ pub async fn address_multisig(
194195
display: bool,
195196
) -> Result<Response, Error> {
196197
let coin_params = params::get(coin);
197-
keypath::validate_address_policy(keypath).or(Err(Error::InvalidInput))?;
198+
keypath::validate_address_policy(keypath, keypath::ReceiveSpend::Receive)
199+
.or(Err(Error::InvalidInput))?;
198200
let account_keypath = &keypath[..keypath.len() - 2];
199201
multisig::validate(multisig, account_keypath)?;
200202
let name = match multisig::get_name(coin, multisig, account_keypath)? {
@@ -233,7 +235,8 @@ async fn address_policy(
233235
) -> Result<Response, Error> {
234236
let coin_params = params::get(coin);
235237

236-
keypath::validate_address_policy(keypath).or(Err(Error::InvalidInput))?;
238+
keypath::validate_address_policy(keypath, keypath::ReceiveSpend::Receive)
239+
.or(Err(Error::InvalidInput))?;
237240

238241
let parsed = policies::parse(policy)?;
239242
parsed.validate(coin)?;

0 commit comments

Comments
 (0)