diff --git a/substrate/client/network/src/protocol.rs b/substrate/client/network/src/protocol.rs index b712ebe515512515bbdfd3bbeb74bd548af39459..2aa29ea2793e33257e9c6a66be27648ffb52f44c 100644 --- a/substrate/client/network/src/protocol.rs +++ b/substrate/client/network/src/protocol.rs @@ -1472,6 +1472,13 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> { who: PeerId, request: message::RemoteReadRequest<B::Hash>, ) { + if request.keys.is_empty() { + debug!(target: "sync", "Invalid remote read request sent by {}", who); + self.behaviour.disconnect_peer(&who); + self.peerset_handle.report_peer(who, rep::BAD_MESSAGE); + return; + } + let keys_str = || match request.keys.len() { 1 => request.keys[0].to_hex::<String>(), _ => format!( @@ -1510,6 +1517,13 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> { who: PeerId, request: message::RemoteReadChildRequest<B::Hash>, ) { + if request.keys.is_empty() { + debug!(target: "sync", "Invalid remote child read request sent by {}", who); + self.behaviour.disconnect_peer(&who); + self.peerset_handle.report_peer(who, rep::BAD_MESSAGE); + return; + } + let keys_str = || match request.keys.len() { 1 => request.keys[0].to_hex::<String>(), _ => format!( diff --git a/substrate/client/rpc/src/state/state_light.rs b/substrate/client/rpc/src/state/state_light.rs index abf4631bb82eb26dcc585f37743bb428e640b319..482eb0723ff80040b9063d52da96e9a10b400a1e 100644 --- a/substrate/client/rpc/src/state/state_light.rs +++ b/substrate/client/rpc/src/state/state_light.rs @@ -325,8 +325,8 @@ impl<Block, F, B, E, RA> StateBackend<B, E, Block, RA> for LightState<Block, F, keys: Option<Vec<StorageKey>> ) { let keys = match keys { - Some(keys) => keys, - None => { + Some(keys) if !keys.is_empty() => keys, + _ => { warn!("Cannot subscribe to all keys on light client. Subscription rejected."); return; }