Review report

bitcoin/bitcoin: PR #35888

1 minor finding · 1 suggestion

Earlier concerns neither republished nor resolved: 2 minor findings. See the Run archive for their assessments.

Findings

Link

[minor] · Private-broadcast witness variants can fail the payload assumption

With -privatebroadcast, an oversized witness variant of a mempool transaction can reach the new assumption, aborting Debug/fuzz builds or causing release builds to record reception of a dropped TX after PONG.

Location: src/net.cpp:4231 (head).

Details and suggested fix

With -privatebroadcast enabled and Tor or I2P reachable, an authenticated sendrawtransaction caller can enlarge a mempool transaction's witness past 4,000,000 serialized bytes without changing its txid. BroadcastTransaction skips test_accept on that txid hit, updates only its local wtxid, and passes the original transaction to the private-broadcast queue. This requires no nonstandard mainnet policy. If a recipient requests the advertised txid, GETDATA handling serializes the stored witness and reaches this Assume. Debug/fuzz builds abort. Release builds drop the TX but still send PING, allowing a matching PONG to mark reception in getprivatebroadcastinfo and select the confirmed-reception stale timer. Reject transactions exceeding MAX_PROTOCOL_MESSAGE_LENGTH with a normal RPC error before storing them for private broadcast, including on the mempool-hit path. A recipient that already knows the txid need not request it; no production occurrence is known.


Optional improvements

Link

[suggestion] · V2 transport still copies the message type without a local bounds check

The new caller-side limit leaves V2's unchecked type copy dependent on caller discipline; a transport-local assertion would protect future direct callers.

Location: src/net.h:127 (head).

Details and suggested fix

V2Transport::SetMessageToSend allocates 1 + MESSAGE_TYPE_SIZE + msg.data.size() bytes in its long-encoding branch, then copies the entire type at offset 1. A type longer than 12 + msg.data.size() writes past the buffer; smaller excess types are silently truncated on the wire. Add Assert(msg.m_type.size() <= CMessageHeader::MESSAGE_TYPE_SIZE) before that copy, matching V1's explicit failure while keeping PushMessage() as the primary guard. Returning false would signal temporary backpressure and leave the offending message queued for retry, while clamping the copy would retain silent truncation. No current caller producing the triggering input was found; this is a defense-in-depth suggestion, not a currently reachable production defect.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.