Skip to content

Malformed leaf_version can terminate qbit-qt Sign/Verify #75

Closed

Description

@kiwidream

Summary

The P2MR proof parser in qbit-qt accepts any JSON number for leaf_version, then converts it with the throwing UniValue::getInt<int>() API.

JSON values such as 192.0, 1e2, or an overflowing integer pass isNum() but fail integer conversion. ParseP2MRProofJson() does not catch that exception, so verification of a malformed pasted proof can escape the dialog's normal error path and terminate the qbit-qt session.

Impact

A counterparty-supplied P2MR proof can cause the entire desktop client to close when the user pastes it into Sign/Verify and clicks Verify. Invalid proofs should instead produce an ordinary validation error while leaving the dialog and application running.

Reproduction

  1. Generate or obtain a structurally valid P2MR proof JSON.
  2. Change leaf_version from an integer such as 192 to one of:
    • 192.0
    • 1e2
    • 2147483648
  3. Paste the proof into qbit-qt Sign/Verify.
  4. Click Verify.
  5. Observe that integer conversion throws instead of returning a normal invalid-proof error, allowing the exception to reach the application's fatal exception path.

Relevant code

ParseP2MRProofJson() in src/qt/signverifymessagedialog.cpp:

  • accepts leaf_version when isNum() is true
  • calls leaf_version.getInt<int>() without a local exception boundary

The verification slot also has no local exception handling, while the runaway-exception path in src/qt/bitcoin.cpp exits the application.

Desired outcome

  • Parse leaf_version without allowing conversion exceptions to escape.
  • Accept only the intended canonical integer representation and supported range.
  • Reject fractional, exponent, negative, unsupported, and overflowing values as ordinary invalid-proof errors.
  • Keep the dialog and application running after malformed input.
  • Clear any stale success result when parsing or verification fails.

Suggested tests

Add Qt click-path regression coverage for:

  • canonical 192
  • 192.0
  • 1e2
  • -1
  • 256
  • integer overflow
  • a very large exponent

Invalid cases should display a normal proof error, leave qbit-qt running, and clear any previous successful verification state.

Activity

  1. added
    bug
    on Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions