How I accidentally broke QBFT finality on Electroneum Smart Chain
The QBFT consensus implementation in Electroneum Smart Chain required only F+1 validator seals to finalise a block, instead of the 2F+1 required by the protocol. An attacker controlling a small number of validators could finalise conflicting blocks, breaking finality and enabling double-spends.
medium.com
Published on medium.com
I was just doing my usual recon on Electroneum Smart Chain — nothing special. No fuzzers, no exploits, just curiosity.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The commit validation check used the wrong threshold: it compared the number of seals to F() instead of 2*F()+1, allowing a block to be finalised with only F+1 seals.
Impact
With only F+1 seals required, a small group of malicious validators could finalise a block while the honest majority finalises a conflicting one, breaking safety and enabling double-spends and permanent forks.
What the attacker needed
Control of F+1 validators; ability to propose or vote on blocks
The fix
The check should require at least 2F+1 seals (or ceil(2N/3)) before accepting a block as finalised.
How it was found
- Examine the consensus engine code and notice the seal validation condition.
- Calculate F() for a validator set size of 9, which gives 2.
- Observe that the implementation requires only F()+1 = 3 seals, while the spec requires 2F()+1 = 5 (or 7 depending on interpretation).
- Write a small test to print the implementation threshold and the spec threshold, confirming the discrepancy.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A blockchain uses a set of computers (validators) to agree on which blocks are final. The agreement rule says you need a large majority (two-thirds) to prevent two different versions of history. This code only required a small minority (one-third), so a few bad validators could finalise a block that the rest of the network disagreed with.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.