-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Don't wrap around when deriving an extended key at a too large depth #25642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is the wrap actually harmful? In any case, current code will never do this, right? |
It is harmful in the sense that this behaviour is not specified by BIP32. We could accept an invalid descriptor or xpub that another software would refuse (or worse, treat differently).
Well, it was triggered by current code. |
ACK 84f86dc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a nit
In some cases we asserted it succeeded, in others we were just ignoring it
It might already fail, and we'll add another failure case.
This issue was reported to me by Marco Falke, and found with the descriptor_parse fuzz target.
84f86dc
to
fb9faff
Compare
re-ACK fb9faff |
Hadn't occurred to me this implicit limit due to the encoding of xpub/xprv. utACK fb9faff |
…at a too large depth fb9faff extended keys: fail to derive too large depth instead of wrapping around (Antoine Poinsot) 8dc6670 descriptor: don't assert success of extended key derivation (Antoine Poinsot) 50cfc9e (pubk)key: mark Derive() as nodiscard (Antoine Poinsot) 0ca258a descriptor: never ignore the return value when deriving an extended key (Antoine Poinsot) d3599c2 spkman: don't ignore the return value when deriving an extended key (Antoine Poinsot) Pull request description: We would previously silently wrap the derived child's depth back to `0`. Instead, explicitly fail when trying to derive an impossible depth, and handle the error in callers. An extended fuzzing corpus of `descriptor_parse` triggered this behaviour, which was reported by MarcoFalke. Fixes bitcoin#25751. ACKs for top commit: achow101: re-ACK fb9faff instagibbs: utACK bitcoin@fb9faff Tree-SHA512: 9f75c23572ce847239bd15e5497df2960b6bd63c61ea72347959d968b5c4c9a4bfeee284e76bdcd7bacbf9eeb70feee85ffd3e316f353ca6eca30e93aafad343
We would previously silently wrap the derived child's depth back to
0
. Instead, explicitly fail when trying to derive an impossible depth, and handle the error in callers.An extended fuzzing corpus of
descriptor_parse
triggered this behaviour, which was reported by MarcoFalke.Fixes #25751.