diff --git a/src/net.cpp b/src/net.cpp index c722ddfcb5..e3938842e3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -761,6 +761,8 @@ int V1Transport::readHeader(Span msg_bytes) } // reject messages larger than MAX_SIZE or MAX_PROTOCOL_MESSAGE_LENGTH + // NOTE: failing to perform this check previously allowed a malicious peer to make us allocate 32MiB of memory per + // connection. See https://bitcoincore.org/en/2024/07/03/disclose_receive_buffer_oom. if (hdr.nMessageSize > MAX_SIZE || hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { LogDebug(BCLog::NET, "Header error: Size too large (%s, %u bytes), peer=%d\n", SanitizeString(hdr.GetMessageType()), hdr.nMessageSize, m_node_id); return -1;