Validators will not be able to sign first batch
The ExtendVoteHandler checks whether a validator was present in the previous batch's validator Merkle tree, but for the first batch there is no previous batch, so the check fails and validators skip signing the first batch.
Source: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/192
Found by
zxriptor
Summary
The check for a validator's presence in the validator Merkle tree of the previous batch will cause an error if the first batch is being processed.
Root Cause
During signing the batch, in ExtendVoteHandler() there is check for the validator being present in the validators tree of the previous (batch.BatchNumber-1) batch:
_, err = h.batchingKeeper.GetValidatorTreeEntry(ctx, batch.BatchNumber-1, h.signer.GetValAddress())
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
h.logger.Info("validator was not in the previous validator tree - not signing the batch")
} else {
h.logger.Error("unexpected error while checking previous validator tree entry", "err", err)
}
return nil, err
}
However, when the first batch is being processed, there is no previous batch, so GetValidatorTreeEntry() will return an error, causing an early exit from ExtendVoteHandler() without signing the batch.
Internal Pre-conditions
Happens for the first batch only.
External Pre-conditions
None
Attack Path
See a Root Cause section.
Impact
Validators will skip signing the first data batch.
PoC
No response
Mitigation
The simplest way is to skip this check if the first batch is being processed.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/sedaprotocol/seda-chain/pull/516
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code unconditionally checks for the validator's presence in the previous batch's validator tree, without handling the case where no previous batch exists.
Impact
Validators will skip signing the first data batch, so the first batch will not be signed.
What the attacker needed
First batch being processed
The fix
The issue was fixed by skipping the check when the first batch is being processed.
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 report has not been written yet. The Original tab links to the source.
Validators are nodes that sign batches of data. Before signing, the code checks if the validator was in the previous batch's list. For the very first batch, there is no previous list, so the check fails and validators do not sign. This means the first batch never gets signed.
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.