From ca7659153ccc6f9eda4374240b98b0f100561805 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 26 Feb 2025 17:13:35 +0100 Subject: [PATCH] add back qbft_message validation --- anchor/common/qbft/src/lib.rs | 6 ++++++ anchor/common/ssv_types/src/consensus.rs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/anchor/common/qbft/src/lib.rs b/anchor/common/qbft/src/lib.rs index 4f496a92..dd14e914 100644 --- a/anchor/common/qbft/src/lib.rs +++ b/anchor/common/qbft/src/lib.rs @@ -214,6 +214,12 @@ where &self, wrapped_msg: &WrappedQbftMessage, ) -> Option<(Option>, OperatorId)> { + // Validate the qbft message + if !wrapped_msg.qbft_message.validate() { + warn!("Invalid qbft_message"); + return None; + } + // Ensure that this message is for the correct round let current_round = self.current_round.get(); if (wrapped_msg.qbft_message.round < current_round as u64) diff --git a/anchor/common/ssv_types/src/consensus.rs b/anchor/common/ssv_types/src/consensus.rs index edaf0fc5..ac238e0f 100644 --- a/anchor/common/ssv_types/src/consensus.rs +++ b/anchor/common/ssv_types/src/consensus.rs @@ -59,6 +59,16 @@ pub struct QbftMessage { pub prepare_justification: Vec, // always without full_data } +impl QbftMessage { + /// Do QBFTMessage specific validation + pub fn validate(&self) -> bool { + if self.qbft_message_type > QbftMessageType::RoundChange { + return false; + } + true + } +} + /// Different states the QBFT Message may represent #[derive(Clone, Debug, PartialEq, PartialOrd, Copy)] pub enum QbftMessageType {