fix(security): prevent signature replay attack in QC verification#290
fix(security): prevent signature replay attack in QC verification#290SherlockShemol wants to merge 1 commit intorelab:mainfrom
Conversation
|
Hi, Thank for contributing this. Furthermore, it does not appear that the test cases utilize the Twins framework. Is that correct? |
Add view validation in VerifyQuorumCert to ensure QC.View matches Block.View, preventing attackers from forging QCs with arbitrary view numbers using signatures from legitimate QCs. Signed-off-by: shemol <shemol@163.com> Signed-off-by: SherlockShemol <shemol@163.com>
2dfc071 to
7e6a2f2
Compare
Hi @leandernikolaus ,
|
Fix Signature Scope Attack Vulnerability
Summary
This PR fixes a critical security vulnerability where attackers can forge QuorumCertificates (QCs) with arbitrary view numbers by replaying signatures from legitimate QCs.
Problem
The
VerifyQuorumCertfunction insecurity/cert/auth.godoes not validate thatQC.ViewmatchesBlock.View. This allows an attacker to:block.ToBytes()Attack Illustration
Real-World Impact
Solution
Add a simple check to ensure
QC.View == Block.View:func (c *Authority) VerifyQuorumCert(qc hotstuff.QuorumCert) error { // ... existing checks ... block, ok := c.blockchain.Get(qc.BlockHash()) if !ok { return fmt.Errorf("block not found: %v", qc.BlockHash()) } + + // Prevent signature replay attacks: QC.View must match Block.View. + if qc.View() != block.View() { + return fmt.Errorf("QC view %d does not match block view %d (possible signature replay attack)", + qc.View(), block.View()) + } return c.Verify(qc.Signature(), block.ToBytes()) }Why This Fix Is Correct
1. All Legitimate QCs Satisfy This Check
The
CreateQuorumCertfunction already setsQC.View = block.View():2. No Breaking Changes
3. Performance
O(signature_verification)O(signature_verification) + O(1)(one integer comparison)Testing
New Test Added
TestVerifyQuorumCert_SignatureReplayAttackTest Results (Before Fix)
Test Results (After Fix)
Full Test Suite
Checklist
Related Issues