Pledge may be out of reward due to the decay in veCRV balance. targetVotes is never reached.
The pledge reward was calculated once at creation from the receiver's veCRV balance, but that balance decays over time, so the reward pool no longer matches the votes still needed to reach targetVotes. A booster could take all the allocated reward while the pledge never reaches its target, and later boosters would be reverted for insufficient rewards.
Submitted by Chom, also found by Jeiwan, Picodes, and KingNFT
Impact
Pledge may be out of reward due to the decay in veCRV balance. The receiver may lose his reward given to boosters but get nothing in return since her targetVotes is never reached.
Proof of Concept
According to Curve documentation at https://curve.readthedocs.io/dao-vecrv.html
A user’s veCRV balance decays linearly as the remaining time until the CRV unlock decreases. For example, a balance of 4000 CRV locked for one year provides the same amount of veCRV as 2000 CRV locked for two years, or 1000 CRV locked for four years.
On creation, targetVotes = 100, balance = 20 -> votesDifference = 80 -> reward is allocated for 80 votes
// 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;
vars.feeAmount = (vars.totalRewardAmount * protocalFeeRatio) / MAX_PCT ;
if(vars.totalRewardAmount > maxTotalRewardAmount) revert Errors.IncorrectMaxTotalRewardAmount();
if(vars.feeAmount > maxFeeAmount) revert Errors.IncorrectMaxFeeAmount();
// Pull all the rewards in this contract
IERC20(rewardToken).safeTransferFrom(creator, address(this), vars.totalRewardAmount);
// And transfer the fees from the Pledge creator to the Chest contract
IERC20(rewardToken).safeTransferFrom(creator, chestAddress, vars.feeAmount);
Then 1 week passed, receiver’s balance decay to 10
On creation, targetVotes = 100, balance = 10 but votesDifference stays 80, and reward has only allocated for 80 votes.
// Rewards are set in the Pledge as reward/veToken/sec
// To find the total amount of veToken delegated through the whole Boost duration
// based on the Boost bias & the Boost duration, to take in account that the delegated amount decreases
// each second of the Boost duration
uint256 totalDelegatedAmount = ((bias * boostDuration) + bias) / 2;
// Then we can calculate the total amount of rewards for this Boost
uint256 rewardAmount = (totalDelegatedAmount * pledgeParams.rewardPerVote) / UNIT;
if(rewardAmount > pledgeAvailableRewardAmounts[pledgeId]) revert Errors.RewardsBalanceTooLow();
pledgeAvailableRewardAmounts[pledgeId] -= rewardAmount;
A booster boosts 80 votes and takes all rewards in the pool. However, only 80 (From booster) + 10 (From receiver) = 90 votes is active. Not 100 votes that receiver promise in the targetVotes.
Then, if another booster tries to boost 10 votes, it will be reverted with RewardsBalanceTooLow since the first booster has taken all reward that is allocated for only 80 votes.
Recommended Mitigation Steps
You should provide a way for the creator to provide additional rewards after the pledge creation. Or provide some reward refreshment function that recalculates votesDifference and transfers the required additional reward.
Kogaroshi (Paladin) confirmed, resolved, and commented:
Changed the logic in PR 2, commit Now the whole amount of votes needed for each second of the Pledge duration is calculated, taking in account the receiver potential veCRV balance, and the veCRV decay.
This should allow to add only the exact amount of reward needed to the Pledge reward pool, and have always the correct amount of rewards to achieve the vote target of the Pledge at all times.
Kogaroshi (Paladin) commented:
If possible, a feedback on the new calculation and logic would be appreciated.
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 reward amount is computed once from the receiver's balance at creation and never recalculated as the veCRV balance decays.
Impact
The pledge creator's reward could be consumed by a booster while the targetVotes is never reached, and later boosters are blocked by a rewards balance error.
What the attacker needed
A pledge creator funds the reward; time passes so veCRV decays; a booster claims the reward
The fix
The logic was changed so the votes needed for each second of the pledge duration are calculated, accounting for the receiver's veCRV balance and its decay, allowing only the exact reward needed to be added.
How it was found
- Create a pledge with targetVotes of 100 while the receiver's balance is 20, so the reward covers 80 votes.
- Wait one week so the receiver's balance decays to 10.
- A booster boosts 80 votes and takes all the rewards in the pool.
- Only 90 votes are active in total, so the target of 100 is not reached.
- A second booster trying to add 10 votes is reverted with RewardsBalanceTooLow.
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 people to add votes until a target is reached. The payout was worked out once, using the receiver's voting power at that moment. That voting power slowly shrinks over time, so the money set aside no longer covers the votes still missing, and the first booster can drain it while the target is never met.
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.