You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] P2P FetchInvDataMsgHandler and InventoryMsgHandler accept empty hash lists and bypass validation / rate limiting #7128
In the latest release GreatVoyage-v4.8.2.4 (also present on master and develop, following #6712 and #6851), both FetchInvDataMsgHandler.check() and InventoryMsgHandler.check() validate duplicate hashes and unknown InventoryType, but neither rejects messages with an empty hashList (ids count == 0).
In production mainnet observations, anomalous inbound peers periodically send empty FetchInvDataMessage packets (ids = [], e.g., every ~300-350ms) without receiving any prior INV from the local node, and are neither rejected nor rate-limited.
isAdvInv() loops 0 times over the empty list and returns true, which skips the entire if (!isAdv) block (including peer.isNeedSyncFromUs() and peer.getP2pRateLimiter().tryAcquire(...)).
check() similarly validates duplicates (hashList.size() != new HashSet<>(hashList).size()) and InventoryType, without rejecting hashList.isEmpty().
Impact
Malformed or malicious peers can send unlimited empty FETCH_INV_DATA / INVENTORY messages without triggering P2pException(TypeEnum.BAD_MESSAGE) or P2P rate limiting, consuming peerWorker thread CPU and allocating temporary collections (HashSet, ArrayList) on every packet.
There is no valid protocol reason for a peer to send an empty Inventory or FetchInvData message.
Expected Behavior
Reject empty hashList in both FetchInvDataMsgHandler.check() and InventoryMsgHandler.check() with P2pException(TypeEnum.BAD_MESSAGE, ...):
// FetchInvDataMsgHandler.javaList<Sha256Hash> hashList = fetchInvDataMsg.getHashList();
if (hashList.isEmpty()) {
thrownewP2pException(TypeEnum.BAD_MESSAGE, "FetchInvData hash list is empty");
}
// InventoryMsgHandler.javaList<Sha256Hash> hashList = inventoryMessage.getHashList();
if (hashList.isEmpty()) {
thrownewP2pException(TypeEnum.BAD_MESSAGE, "Inventory hash list is empty");
}
#7123 cleanly closes the empty-payload bypass in FetchInvDataMsgHandler.check(), bringing it in line with SyncBlockChainMsgHandler and ChainInventoryMsgHandler. However, the remaining two list-based P2P message handlers on release_v4.8.3 still accept empty payloads without throwing BAD_MESSAGE:
Validates duplicate hashes (hashList.size() != new HashSet<>(hashList).size()) and InventoryType, but does not reject hashList.isEmpty().
Because P2pEventHandlerImpl.checkInvRateLimit() (lines 220-245) counts msg.getInventory().getIdsCount() (which is 0 for an empty message), a peer can send unlimited empty INVENTORY packets (TRX or BLOCK) while completely bypassing the 10-second rate limit and never triggering BAD_PROTOCOL.
Iterates over msg.getTransactions().getTransactionsList() without checking list.isEmpty().
An empty TransactionsMessage (transactions = []) executes 0 loop iterations, bypassing the unsolicited-transaction check (peer.getAdvInvRequest().containsKey(item)), allowing a peer to send unlimited empty TRXS packets without disconnection.
Suggested Fix
Align both handlers with #7123 (FetchInvDataMsgHandler), SyncBlockChainMsgHandler, and ChainInventoryMsgHandler by rejecting empty lists as BAD_MESSAGE:
// InventoryMsgHandler.java (in check())List<Sha256Hash> hashList = inventoryMessage.getHashList();
if (hashList.isEmpty()) {
thrownewP2pException(TypeEnum.BAD_MESSAGE, "Inventory ids is empty");
}
// TransactionsMsgHandler.java (in check())List<Transaction> list = msg.getTransactions().getTransactionsList();
if (list.isEmpty()) {
thrownewP2pException(TypeEnum.BAD_MESSAGE, "Transactions list is empty");
}
Activity
FinchAlex commentedon Nov 26, 2026
Follow-up to #7123 (
release_v4.8.3).#7123 cleanly closes the empty-payload bypass in
FetchInvDataMsgHandler.check(), bringing it in line withSyncBlockChainMsgHandlerandChainInventoryMsgHandler. However, the remaining two list-based P2P message handlers onrelease_v4.8.3still accept empty payloads without throwingBAD_MESSAGE:InventoryMsgHandler.check()(framework/src/main/java/org/tron/core/net/messagehandler/InventoryMsgHandler.java, lines 56-70):hashList.size() != new HashSet<>(hashList).size()) andInventoryType, but does not rejecthashList.isEmpty().P2pEventHandlerImpl.checkInvRateLimit()(lines 220-245) countsmsg.getInventory().getIdsCount()(which is0for an empty message), a peer can send unlimited emptyINVENTORYpackets (TRXorBLOCK) while completely bypassing the 10-second rate limit and never triggeringBAD_PROTOCOL.TransactionsMsgHandler.check()(framework/src/main/java/org/tron/core/net/messagehandler/TransactionsMsgHandler.java, lines 150-170):msg.getTransactions().getTransactionsList()without checkinglist.isEmpty().TransactionsMessage(transactions = []) executes 0 loop iterations, bypassing the unsolicited-transaction check (peer.getAdvInvRequest().containsKey(item)), allowing a peer to send unlimited emptyTRXSpackets without disconnection.Suggested Fix
Align both handlers with #7123 (
FetchInvDataMsgHandler),SyncBlockChainMsgHandler, andChainInventoryMsgHandlerby rejecting empty lists asBAD_MESSAGE:317787106 commentedon Nov 26, 2026
@FinchAlex Thansk for your remind. It will be fixed in v4.8.3, see this #7129.
halibobo1205 commentedon Nov 26, 2026
cc @xxo1shine