Repository navigation
feat(signmessage): harden QR decoding and derivation path parsing (fixes #1062) - #1063
muskan-creates352 wants to merge 4 commits into
Conversation
wolgwang1729
left a comment
There was a problem hiding this comment.
Tested this branch against an automated fuzzer (published on my fork).
Adding a try...except block in SeedSignMessageStartView only patches the symptom at the first screen. The core issue is that parse_derivation_path() still marks invalid derivation paths as clean_match=True. Because they are marked clean, they bypass StartView and crash downstream in ConfirmAddressView:
m/84h/0h/0h/0/2147483648(raisesHDError: Can't do hardened with public key)m/84h/0h/invalid_acc/0/0(raisesValueError: invalid literal for int())m/99h/0h/0h/0/0(raisesException: Custom derivation not supported)
…ean_match to standard paths
|
Thank you so much for the thorough review and for running the automated fuzzer against this branch, @wolgwang1729! I've addressed the root causes in
|
|
Commit d120562 just patches against the specific fuzzer README vectors without understanding the architecture. It introduces dead code in |
…rivation path parsing
|
Thank you for calling this out and for the direct feedback, @wolgwang1729 — you're completely right regarding the I've taken a step back and addressed the root architectural issues in commit 24726fb:
|
Fixes #1062
(Follow-up to #1059 based on feedback from @wolffgang1729)
Description
This PR addresses the follow-up edge cases identified in #1059 to make the
signmessageQR parsing and verification pipeline robust end-to-end:Short/Partial Derivation Paths Downstream:
embit_utils.parse_derivation_path()now defensively checks that the derivation path has sufficient sections (len(sections) >= 3and starts with"m") before indexing.m/84hor0/0, it safely returnsclean_match: Falsewithout raising an unhandledIndexError.SeedSignMessageStartViewcatches short/custom paths and routes them cleanly toNotYetImplementedView.Multisig Derivation Paths (BIP-48 /
m/48h):embit_utils.parse_derivation_path()raisesNotImplementedError("Signing messages for multisig paths not supported")when encountering48h.SeedSignMessageStartViewhandlesNotImplementedErrorgracefully and routes users toNotYetImplementedViewexplaining that multisig message signing is not yet supported.Strict Command Token Enforcement:
SignMessageQrDecoder.add()now validatesparts[0] == "signmessage"to strictly enforce the command token and reject malformed command variations (e.g.,signmessage_v2).Robust Format Prefix Splitting:
segment.split(format_prefix, 1), the decoder now searches for theformat_prefixspecifically after the derivation path token. This prevents premature splitting if a derivation path contains the substringascii:.Testing
tests/test_sign_message_qr_decoder.py: Added tests for strict command matching, path containingascii:, empty message parsing, and multiple colons in message (10/10 passed).tests/test_embit_utils.py: Added tests for short/invalid paths and BIP-48 multisig paths (8/8 passed).tests/test_flows_seed.py: Updatedtest_sign_message_unsupported_derivation_flowto verify that short and multisig derivation paths route toNotYetImplementedView(21/21 passed).