without checking _minSubmissionRequired, there can be Division error in BlockSpecimenProofChain::finalizeSpecimenSession
Summary
In BlockSpecimenProofChain::finalizeSpecimenSession, when the number of submissions is sufficient and the quorum is achieved, there can be zero division error
In rare case, when accidently the _minSubmissionRequired is set to 0, then there's no way to prevent 0 division in finalizeSpecimenSession , It can halt the finalizing process and cause big problem.
Impact
It can halt the finalizing specimen session process and cause loss of session.
Code Snippet
for (uint256 i = 0; i < blockSpecimenHashesLength; i++) {
rawBlockHash = blockHashesRaw[i];
BlockProperties storage bh = session.blockProperties[rawBlockHash];
for (uint256 j = 0; j < bh.specimenHashes.length; j++) {
specimenHash = bh.specimenHashes[j];
uint256 len = bh.participants[specimenHash].length;
contributorsN += len;
if (len > max) {
max = len;
agreedBlockHash = rawBlockHash;
agreedSpecimenHash = specimenHash;
}
}
}
// check if the number of submissions is sufficient and if the quorum is achieved
if (_minSubmissionsRequired <= max && (max * _DIVIDER) / contributorsN > _blockSpecimenQuorum) {
// TODO: doesn't free session space. Though it should.
_finalizeWithParticipants(session, chainId, blockHeight, agreedBlockHash, agreedSpecimenHash);
} else emit QuorumNotReached(chainId, blockHeight);
In here, need to make sure the _minSubmissionsRequired is greater than 0
Tool used
Manual Review
Recommendation
In finalizeSpecimenSession, please check the _minSubmissionsRequired is greater than 0
themis210
medium
without checking _minSubmissionRequired, there can be Division error in BlockSpecimenProofChain::finalizeSpecimenSession
Summary
In BlockSpecimenProofChain::finalizeSpecimenSession, when the number of submissions is sufficient and the quorum is achieved, there can be zero division error
https://github.com/sherlock-audit/2023-11-covalent/blob/main/cqt-staking/contracts/BlockSpecimenProofChain.sol#L431 Here, when accidently the _minSubmissionRequired is set to 0, it can possible make 0 division.
Vulnerability Detail
In rare case, when accidently the
_minSubmissionRequired
is set to 0, then there's no way to prevent 0 division infinalizeSpecimenSession
, It can halt the finalizing process and cause big problem.Impact
It can halt the finalizing specimen session process and cause loss of session.
Code Snippet
In here, need to make sure the
_minSubmissionsRequired
is greater than 0Tool used
Manual Review
Recommendation
In
finalizeSpecimenSession
, please check the _minSubmissionsRequired is greater than 0