The height comparison below requires an integer. An error raised in this function can cause the network thread to crash.
So just disconnect the server if a non-int height happens.
Add non-regression tests for this and for D20584
Differential D20786
[electrum] guard against non-int height in on_notify_header Authored by PiRK on Oct 8 2026, 06:42. Project Tags None Referenced Files None Subscribers None
Details
The height comparison below requires an integer. An error raised in this function can cause the network thread to crash. Add non-regression tests for this and for D20584 python test_runner.py Start Electrum ABC and check our current servers don't get disconnected
Diff Detail
Event TimelineComment Actions Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed. Diff : committed changes only (\(\ ──────────────────────────────────────────────────────────────────────── minor [Functional Correctness] → ]8;;vscode://file//work/electrum/electrumabc/network.py:1837electrum/electrumabc/network.py:1837]8;; Reject boolean header heights. Python treats True and False as integers, so this check accepts a boolean from a server. If VERIFICATION_BLOCK_HEIGHT is None, the later checkpoint calculation uses that boolean as a height and requests headers at a negative height instead of disconnecting. Require type(header_dict["height"]) is int, and test boolean heights with the verification height set to None. ──────────────────────────────────────── Minor 1 2 files reviewed:
──────────────────────────────────────── Print all AI prompts: coderabbit review --show-prompts Comment Actions Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed. Diff : committed changes only (\(\ ──────────────────────────────────────────────────────────────────────── minor [Functional Correctness] → ]8;;vscode://file//work/electrum/electrumabc/network.py:1837electrum/electrumabc/network.py:1837]8;; Reject bool values in the height type check. bool is a subclass of int in Python. isinstance(True, int) returns True, so a server can send "height": true and pass this validation. The code then treats it as height 1. If networks.net.VERIFICATION_BLOCK_HEIGHT is None, the later height check is skipped. The bogus value then reaches deserialize_header and is stored in interface.tip. This is a narrow case, but the check exists to reject malformed server data. Exclude bool explicitly. Add True to the bad-height cases in test_connection_down_when_height_not_int. Proposed fix - or not isinstance(header_dict["height"], int) + or isinstance(header_dict["height"], bool) + or not isinstance(header_dict["height"], int) ──────────────────────────────────────── Minor 1 2 files reviewed:
──────────────────────────────────────── Print all AI prompts: coderabbit review --show-prompts Comment Actions Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed. Diff : committed changes only (\(\ ──────────────────────────────────────────────────────────────────────── minor [Functional Correctness] → ]8;;vscode://file//work/electrum/electrumabc/network.py:1837electrum/electrumabc/network.py:1837]8;; Reject bool heights explicitly. isinstance(True, int) is True, so a bool height passes this check. The test comment says True and False are rejected only because of the `height Proposed fix - or not isinstance(header_dict["height"], int) + or not isinstance(header_dict["height"], int) + or isinstance(header_dict["height"], bool) ──────────────────────────────────────── Minor 1 2 files reviewed:
──────────────────────────────────────── Print all AI prompts: coderabbit review --show-prompts |