Reward can be over- or undercounted in extendPledge and increasePledgeRewardPerVote
The pledge contract caches the number of missing votes when a pledge is created and reuses that stale value when the pledge is extended or its reward per vote is increased. If the receiver's voting balance has changed since creation, the total reward is miscalculated, so the creator can overpay for rewards that can never be claimed or underpay so the target is never reached.
Submitted by Jeiwan, also found by Aymen0909, Trust, 0xDjango, Chom, Lambda, and Ruhum
Impact
Total reward amount in extendPledge and increasePledgeRewardPerVote can be calculated incorrectly due to cached pledgeParams.votesDifference, which can lead to two outcomes:
- total reward amount is higher, thus a portion of it won’t be claimable;
- total reward amount is lower, thus the pledge target won’t be reached.
Proof of Concept
When a pledge is created, the creator chooses the target–the total amount of votes they want to reach with the pledge. Based on a target, the number of missing votes is calculated, which is then used to calculated the total reward amount (WardenPledge.sol#L325-L327):
function createPledge(
address receiver,
address rewardToken,
uint256 targetVotes,
uint256 rewardPerVote, // reward/veToken/second
uint256 endTimestamp,
uint256 maxTotalRewardAmount,
uint256 maxFeeAmount
) external whenNotPaused nonReentrant returns(uint256){
...
// Get the missing votes for the given receiver to reach the target votes
// We ignore any delegated boost here because they might expire during the Pledge duration
// (we can have a future version of this contract using adjusted_balance)
vars.votesDifference = targetVotes - votingEscrow.balanceOf(receiver);
vars.totalRewardAmount = (rewardPerVote * vars.votesDifference * vars.duration) / UNIT;
...
}
When extending a pledge or increasing a pledge reward per vote, current veToken balance of the pledge’s receiver (votingEscrow.balanceOf(receiver)) can be different from the one it had when the pledge was created (e.g. the receiver managed to lock more CRV or some of locked tokens have expired). However pledgeParams.votesDifference is not recalculated (WardenPledge.sol#L387, WardenPledge.sol#L432):
function extendPledge(
uint256 pledgeId,
uint256 newEndTimestamp,
uint256 maxTotalRewardAmount,
uint256 maxFeeAmount
) external whenNotPaused nonReentrant {
...
Pledge storage pledgeParams = pledges[pledgeId];
...
uint256 totalRewardAmount = (pledgeParams.rewardPerVote * pledgeParams.votesDifference * addedDuration) / UNIT;
...
}
function increasePledgeRewardPerVote(
uint256 pledgeId,
uint256 newRewardPerVote,
uint256 maxTotalRewardAmount,
uint256 maxFeeAmount
) external whenNotPaused nonReentrant {
...
Pledge storage pledgeParams = pledges[pledgeId];
...
uint256 totalRewardAmount = (rewardPerVoteDiff * pledgeParams.votesDifference * remainingDuration) / UNIT;
...
}
This can lead to two consequences:
-
When receiver’s veToken balance has increased (i.e.
votesDifferencegot in fact smaller), pledge creator will overpay for pledge extension and pledge reward per vote increase. This extra reward cannot be received by pledgers because a receiver cannot get more votes thanpledgeParams.targetVotes(which is not updated when modifying a pledge):function _pledge(uint256 pledgeId, address user, uint256 amount, uint256 endTimestamp) internal { ... // Check that this will not go over the Pledge target of votes if(delegationBoost.adjusted_balance_of(pledgeParams.receiver) + amount > pledgeParams.targetVotes) revert Errors.TargetVotesOverflow(); ... } -
When receiver’s veToken balance has decreased (i.e.
votesDifferencegot in fact bigger), the pledge target cannot be reached because the reward amount was underpaid inextendPledge/increasePledgeRewardPerVote.
Recommended Mitigation Steps
Consider updating votesDifference when extending a pledge or increasing a pledge reward per vote.
Kogaroshi (Paladin) confirmed and commented:
As stated in #91, new method for needed votes & needed reward calculations is introduced in this commit, allowing to get the exact amount of reward token the Pledge creator should pay when extending the Pledge or increasing the
rewardPerVote.
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 contract stores the missing-vote count at pledge creation and never recalculates it in extendPledge or increasePledgeRewardPerVote, even though the receiver's voting balance can change.
Impact
The creator can overpay for rewards that cannot be claimed because the target vote cap is unchanged, or underpay so the pledge target cannot be reached; the text does not describe an exploit path beyond this miscalculation.
What the attacker needed
A pledge exists; receiver's voting balance changed since creation; creator extends or raises reward per vote
The fix
The project confirmed the issue and introduced a new method for calculating needed votes and rewards so the exact amount is paid when extending a pledge or increasing the reward per vote.
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 pledge pays out a reward for each vote a receiver is missing to reach a target. The contract works out that missing amount once, when the pledge is made, and stores it. Later, when someone extends the pledge or raises the reward per vote, the contract reuses the old stored number even though the receiver's actual voting power may have changed, so the money set aside is 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.