Skip to content

Commit

Permalink
fix(crypto/ledger): Improve error message when deriving paths (#22116)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5bed965)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
raynaudoe authored and mergify[bot] committed Oct 3, 2024
1 parent 892138b commit 524c259
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Improvements

<<<<<<< HEAD
* (genutil) [#21701](https://github.com/cosmos/cosmos-sdk/pull/21701) Improved error messages for genesis validation.
* (runtime) [#21704](https://github.com/cosmos/cosmos-sdk/pull/21704) Move `upgradetypes.StoreLoader` to runtime and alias it in upgrade for backward compatibility.
* (sims)[#21613](https://github.com/cosmos/cosmos-sdk/pull/21613) Add sims2 framework and factory methods for simpler message factories in modules
=======
* (crypto/ledger) [#22116](https://github.com/cosmos/cosmos-sdk/pull/22116) Improve error message when deriving paths using index >100
* (sims) [#21613](https://github.com/cosmos/cosmos-sdk/pull/21613) Add sims2 framework and factory methods for simpler message factories in modules
>>>>>>> 5bed9658a (fix(crypto/ledger): Improve error message when deriving paths (#22116))
* (modules) [#21963](https://github.com/cosmos/cosmos-sdk/pull/21963) Duplicatable metrics are no more collected in modules. They were unecessary overhead.

### Bug Fixes
Expand Down
6 changes: 6 additions & 0 deletions crypto/ledger/ledger_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (types.PubKey, error
func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (types.PubKey, string, error) {
publicKey, addr, err := device.GetAddressPubKeySECP256K1(path.DerivationPath(), hrp)
if err != nil {
// Check special case if user is trying to use an index > 100
if path.AddressIndex > 100 {
return nil, "", fmt.Errorf("%w: cannot derive paths where index > 100: %s "+
"This is a security measure to avoid very hard to find derivation paths introduced by a possible attacker. "+
"You can disable this by setting expert mode in your ledger device. Do this at your own risk", err, path)
}
return nil, "", fmt.Errorf("%w: address rejected for path %s", err, path)
}

Expand Down

0 comments on commit 524c259

Please sign in to comment.