Skip to content

fix(key-wallet): check child indexes in the dip9 path builders #1297

Closed

Description

@xdustinface

DerivationPath::bip_44_payment_path (and the other dip9.rs path builders) construct ChildNumber::Hardened { index } and ChildNumber::Normal { index } directly from caller u32s, without the 31-bit check that ChildNumber::from_hardened_idx / from_normal_idx apply.

An account of 0x8000_0000 therefore builds the same path as account 0, because a hardened child serializes as index | 1 << 31. An address_index of 0x8000_0000 or more builds a Normal child that is not canonical. DerivationPath::from_str and AccountType::derivation_path reject both values, so the same request gives different answers depending on which constructor a caller uses.

Found in review of dashpay/platform#5727, whose platform_wallet_bip44_address_from_mnemonic passes user-supplied indexes to bip_44_payment_path.

Proposed fix: make the path builders fallible (from_hardened_idx / from_normal_idx) and return the error, then cover 0x7fff_ffff against 0x8000_0000 in tests. Callers propagate the error instead of adding their own range checks.

Activity

  1. self-assigned this
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions