-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify consensus message author matches with the sender #15386
Changes from 1 commit
11b5b0a
438dcb7
5e12602
bf2b3f1
042a281
be4a116
799e44c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1446,6 +1446,7 @@ impl<P: OnChainConfigProvider> EpochManager<P> { | |
BlockStage::EPOCH_MANAGER_RECEIVED, | ||
); | ||
} | ||
self.check_author(peer_id, &consensus_msg)?; | ||
// we can't verify signatures from a different epoch | ||
let maybe_unverified_event = self.check_epoch(peer_id, consensus_msg).await?; | ||
|
||
|
@@ -1512,6 +1513,46 @@ impl<P: OnChainConfigProvider> EpochManager<P> { | |
Ok(()) | ||
} | ||
|
||
fn check_author(&mut self, peer_id: AccountAddress, msg: &ConsensusMsg) -> anyhow::Result<()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this a bug fix, how about a test that verifies the bug is actually fixed ? |
||
let author = match msg { | ||
ConsensusMsg::CommitMessage(commit) => commit.author(), | ||
ConsensusMsg::ProposalMsg(proposal) => proposal.proposal().author(), | ||
ConsensusMsg::VoteMsg(vote) => Some(vote.vote().author()), | ||
ConsensusMsg::OrderVoteMsg(order_vote) => Some(order_vote.order_vote().author()), | ||
ConsensusMsg::CommitVoteMsg(commit_vote) => Some(commit_vote.author()), | ||
ConsensusMsg::BatchMsg(batch) => Some(batch.author()), | ||
ConsensusMsg::RoundTimeoutMsg(round_timeout) => Some(round_timeout.author()), | ||
ConsensusMsg::BatchResponse(batch_response) => Some(batch_response.author()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this works too, even this doesn't go through this path (it goes through rpc), this is the batch author which is not necessarily the responser. |
||
ConsensusMsg::BatchRequestMsg(batch_request) => Some(batch_request.source()), | ||
|
||
ConsensusMsg::CommitDecisionMsg(_) | ||
| ConsensusMsg::DAGMessage(_) | ||
| ConsensusMsg::EpochChangeProof(_) | ||
| ConsensusMsg::EpochRetrievalRequest(_) | ||
| ConsensusMsg::ProofOfStoreMsg(_) | ||
| ConsensusMsg::SyncInfo(_) | ||
| ConsensusMsg::RandGenMessage(_) | ||
| ConsensusMsg::BatchResponseV2(_) | ||
| ConsensusMsg::BlockRetrievalRequest(_) | ||
| ConsensusMsg::BlockRetrievalResponse(_) | ||
// For SignedBatchInfo, the verify function will check the author | ||
vusirikala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ConsensusMsg::SignedBatchInfo(_) => None, | ||
}; | ||
|
||
if let Some(author) = author { | ||
if author != peer_id { | ||
bail!( | ||
vusirikala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Received {:?} message from peer {} with different author {}", | ||
discriminant(msg), | ||
peer_id, | ||
author | ||
); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn check_epoch( | ||
&mut self, | ||
peer_id: AccountAddress, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this should be part of the
UnverifiedEvent.verify
check to keep them all in one place @zekun000 .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the sender verification checks to individual verify functions.