Skip to content

Commit

Permalink
chore: limit initial status size (#12324)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 5, 2024
1 parent 4222cbe commit 556995f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/net/eth-wire/src/ethstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use tracing::{debug, trace};
// https://github.com/ethereum/go-ethereum/blob/30602163d5d8321fbc68afdcbbaf2362b2641bde/eth/protocols/eth/protocol.go#L50
pub const MAX_MESSAGE_SIZE: usize = 10 * 1024 * 1024;

/// [`MAX_STATUS_SIZE`] is the maximum cap on the size of the initial status message
pub(crate) const MAX_STATUS_SIZE: usize = 500 * 1024;

/// An un-authenticated [`EthStream`]. This is consumed and returns a [`EthStream`] after the
/// `Status` handshake is completed.
#[pin_project]
Expand Down Expand Up @@ -97,7 +100,7 @@ where
}
}?;

if their_msg.len() > MAX_MESSAGE_SIZE {
if their_msg.len() > MAX_STATUS_SIZE {
self.inner.disconnect(DisconnectReason::ProtocolBreach).await?;
return Err(EthStreamError::MessageTooBig(their_msg.len()))
}
Expand Down

0 comments on commit 556995f

Please sign in to comment.