net: reject oversized outbound messages

bitcoin/bitcoin: PR #35888

1 minor finding · 1 suggestion

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Private broadcast can acknowledge a TX dropped locally

With relaxed test-chain policy, private broadcast can record reception of an oversized transaction that the new send guard drops; abort-on-failed-Assume builds instead abort, and no default-configuration trigger was found.

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

Details and suggested fix

With -privatebroadcast=1 and a usable Tor/I2P route, sendrawtransaction can schedule an effective transaction above MAX_PROTOCOL_MESSAGE_LENGTH if test_accept admits it. This requires a test chain with -acceptnonstdtxn and the debug-only -limitclustersize option raised sufficiently above roughly 1000 kvB. There is no serialized-size check before InitiateTxBroadcastPrivate returns success. When a peer requests the transaction, PushMessage drops the TX in release builds, but the GETDATA handler still sends PING. A matching PONG then records a false received timestamp in getprivatebroadcastinfo and disconnects the peer. That confirmation affects retry timing but does not establish propagation or resolve the transaction. With failed assumptions enabled, the TX response would instead abort the node. These consequences follow from source inspection, not a runtime reproduction.

Reject an oversized effective transaction before scheduling private broadcast, after the mempool substitution. This preserves the intended behavior of rebroadcasting the validated mempool transaction when the RPC supplies an oversized witness variant. Keep the PushMessage assumption as a backstop.


Optional improvements

Link

[suggestion] · Outbound-limit test does not require failed assumptions

Replacing Assume with a plain size check and early return would leave all assertions in outbound_message_limits passing, losing coverage of the intended debug-build failure.

Location: src/test/net_tests.cpp:1448 (head).

Details and suggested fix

BOOST_CHECK(reject) runs only when PushMessage throws. For either rejected case, returning quietly leaves the queue at its expected size and satisfies the test. Record a threw flag in the catch and add if constexpr (G_ABORT_ON_FAILED_ASSUME) BOOST_CHECK_EQUAL(threw, reject);. The gate is necessary because the exception mock changes how an abort is handled, not whether Assume checks are enabled. Keep the existing queue-size assertions to cover release-build drops.


Coverage details

Earlier concerns

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