Repository navigation
Description
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
- Generate or obtain a structurally valid P2MR proof JSON.
- Change
leaf_versionfrom an integer such as192to one of:192.01e22147483648
- Paste the proof into qbit-qt Sign/Verify.
- Click Verify.
- 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_versionwhenisNum()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_versionwithout 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.01e2-1256- 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