withdrawFees does not update checkpoint
The withdrawFees function in BondingManager updates a delegator's lastClaimRound and bondedAmount through autoClaimEarnings but never calls _checkpointBondingState, so BondingVotes retains stale checkpoint data. An attacker could exploit this inconsistency to obtain an incorrect voting power in BondingVotes.
ADM Follow with rvierdiiev, twicek and 1 other
Originally disclosed on Code4rena
Submitted by ADM, also found by rvierdiiev, twicek, and HChang26
BondingVotes may have stale data due to missing checkpoint in BondingManager#withdrawFees().
Proof of Concept
The withdrawFee function has the autoClaimEarnings modifier:
function withdrawFees(address payable _recipient, uint256 _amount) external whenSystemNotPaused currentRoundInitialized autoClaimEarnings(msg.sender) {
which calls _autoClaimEarnings:
modifier autoClaimEarnings(address _delegator) {
_autoClaimEarnings(_delegator);
_;
which calls updateDelegatorWithEarnings:
function _autoClaimEarnings(address _delegator) internal {
uint256 currentRound = roundsManager().currentRound();
uint256 lastClaimRound = delegators[_delegator].lastClaimRound;
if (lastClaimRound < currentRound) {
updateDelegatorWithEarnings(_delegator, currentRound, lastClaimRound);
}
}
During updateDelegatorWithEarnings, both delegator.lastClaimRound and delegator.bondedAmount can be assigned new values.
del.lastClaimRound = _endRound;
// Rewards are bonded by default
del.bondedAmount = currentBondedAmount;
However, during the lifecycle of all these functions, _checkpointBondingState is never called either directly or through the autoCheckpoint modifier resulting in lastClaimRound & bondedAmount’s values being stale in BondingVotes.sol.
Recommended Mitigation Steps
Add autoCheckpoint modifier to the withdrawFees function.
victorges (Livepeer) confirmed
victorges (Livepeer) mitigated:
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
Likely the withdrawFees function lacks the autoCheckpoint modifier, so changes to lastClaimRound and bondedAmount are not propagated to BondingVotes.
Impact
BondingVotes could hold stale checkpoint data, potentially leading to incorrect voting power calculations.
What the attacker needed
A delegator with pending earnings; ability to call withdrawFees
The fix
The withdrawFees function should be fixed by adding the autoCheckpoint modifier.
How it was found
- Call withdrawFees, which triggers autoClaimEarnings.
- autoClaimEarnings calls updateDelegatorWithEarnings, which updates lastClaimRound and bondedAmount.
- No checkpoint is made to BondingVotes, leaving its data stale.
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.
A smart contract keeps a record of how much each person has staked and when that was last updated. When someone withdraws fees, the staking record changes, but a separate voting contract is not told about the change, so it keeps using old numbers. This means a person's voting power could be wrong.
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.