Skip to content

String deriviation paths cause invalid hardening value due to Lodash call #3358

@SmartArray

Description

@SmartArray

We found a flaw with the string typed key derivation function at the following call:

HDPrivateKey.isValidPath = function(arg, hardened) {
if (_.isString(arg)) {
var indexes = HDPrivateKey._getDerivationIndexes(arg);
return indexes !== null && _.every(indexes, HDPrivateKey.isValidPath);
}

_.every calls the function HDPrivateKey.isValidPath with two args:

  1. The first arg is the expected parsed number of the derivation path
  2. The second (unexpected) arg is the index of the root array which toggles the hardening parameter of the function (isValidPath), which is clearly unintended

An easy fix is to introduce an anonymous function as shown in this PR: #3359

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions