Commit b7f6f1a
committed
fix: add Parent-QC consistency check to prevent malformed blocks
The protocol was missing validation that Block.Parent() must equal
Block.QuorumCert().BlockHash(). This allows Byzantine leaders to create
malformed blocks where Parent points to an early block while QC points
to the latest valid block.
Attack scenario:
- Byzantine leader creates block F with F.Parent = A (early block)
- F.QC = QC(E) which is a valid existing QC pointing to latest block E
- VoteRule accepts because Liveness condition only checks QC view
- Voter.Verify had no Parent-QC consistency check
- Honest nodes would vote for the malformed block
Impact without fix:
- Blockchain data structure inconsistency (Parent chain diverges from QC chain)
- blockchain.Extends() returns incorrect results
- Potential liveness failures for subsequent proposals
Fix: Add validation in Voter.Verify() that rejects blocks where
Block.Parent() != Block.QuorumCert().BlockHash()
Test: twins/parent_qc_mismatch_test.go verifies the fix works.
Signed-off-by: SherlockShemol <shemol@163.com>1 parent d8cd2d0 commit b7f6f1a
4 files changed
Lines changed: 756 additions & 3 deletions
File tree
- protocol
- consensus
- twins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
59 | 86 | | |
60 | 87 | | |
| 88 | + | |
61 | 89 | | |
62 | 90 | | |
63 | 91 | | |
| |||
0 commit comments