Skip to content

Commit 3d26b23

Browse files
authored
fix(validation): Check the signatures of the justifications' justifications (#604)
Messages used in round change justifications can have justifications themselves. Check those. Decode the justifications and call `validate_justifications` on them. Co-Authored-By: Daniel Knopik <[email protected]>
1 parent 59aa800 commit 3d26b23

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

anchor/message_validator/src/consensus_message.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,15 @@ pub(crate) fn validate_consensus_message_semantics(
142142
});
143143
}
144144

145-
validate_justifications(consensus_message, operator_pub_keys)?;
145+
validate_justifications(consensus_message, operator_pub_keys, true)?;
146146

147147
Ok(())
148148
}
149149

150150
pub(crate) fn validate_justifications(
151151
consensus_message: &QbftMessage,
152152
operator_pub_keys: &HashMap<OperatorId, Rsa<Public>>,
153+
check_inner_justifications: bool,
153154
) -> Result<(), ValidationFailure> {
154155
// Rule: Can only exist for Proposal messages
155156
let prepare_justifications = &consensus_message.prepare_justification;
@@ -172,7 +173,17 @@ pub(crate) fn validate_justifications(
172173
.iter()
173174
.chain(round_change_justifications.iter())
174175
.try_for_each(|signed_message| {
175-
verify_message_signatures(signed_message, operator_pub_keys)
176+
verify_message_signatures(signed_message, operator_pub_keys)?;
177+
// Also check the justifications' justifications
178+
if check_inner_justifications {
179+
validate_justifications(
180+
&QbftMessage::from_ssz_bytes(signed_message.ssv_message().data())
181+
.map_err(|_| ValidationFailure::MalformedJustifications)?,
182+
operator_pub_keys,
183+
false,
184+
)?;
185+
}
186+
Ok(())
176187
})?;
177188

178189
Ok(())

anchor/message_validator/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ pub enum ValidationFailure {
153153
want: usize,
154154
},
155155
DifferentProposalData,
156-
MalformedPrepareJustifications,
156+
MalformedJustifications,
157157
UnexpectedPrepareJustifications,
158-
MalformedRoundChangeJustifications,
159158
UnexpectedRoundChangeJustifications,
160159
NoPartialSignatureMessages,
161160
NoValidators,

0 commit comments

Comments
 (0)