Skip to content

Commit ad616b6

Browse files
committed
doc: net: mention past vulnerability as rationale to limit incoming message size
1 parent 4489117 commit ad616b6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ int V1Transport::readHeader(Span<const uint8_t> msg_bytes)
761761
}
762762

763763
// reject messages larger than MAX_SIZE or MAX_PROTOCOL_MESSAGE_LENGTH
764+
// NOTE: failing to perform this check previously allowed a malicious peer to make us allocate 32MiB of memory per
765+
// connection. See https://bitcoincore.org/en/2024/07/03/disclose_receive_buffer_oom.
764766
if (hdr.nMessageSize > MAX_SIZE || hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) {
765767
LogDebug(BCLog::NET, "Header error: Size too large (%s, %u bytes), peer=%d\n", SanitizeString(hdr.GetMessageType()), hdr.nMessageSize, m_node_id);
766768
return -1;

0 commit comments

Comments
 (0)