Rewards for the first epoch at rewards distribu
The rewards distributor allocates part of the first epoch's rewards to a snapshot taken before any veALCX holder existed, so those tokens can never be claimed. An attacker gains nothing directly, but a portion of rewards is permanently frozen in the contract.
Originally disclosed on Immunefi
- Disclosed after under an hour
31484 - [SC - High] Rewards for the first epoch at rewards distribu...
Submitted on May 20th 2024 at 06:25:57 UTC by @MahdiKarimi for Boost | Alchemix
Report ID: #31484
Report type: Smart Contract
Report severity: High
Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RewardsDistributor.sol
Impacts:
- Permanent freezing of unclaimed yield
Description
Brief/Intro
Some parts of rewards at rewards distributor would be lost
Vulnerability Details
RewardsDistributor distributes ALCX rewards to veALCX holders, rewards are distributed based on the balance of users at the end of an epoch, for the first time that the minter distributes rewards, some part of it is being allocated to the first epoch which can be withdrawn only if there was a user at the start of the first epoch ( end of last epoch ) but since rewards distributor and voting escrow ( mints veALCX ) are being deployed in the same time so there is no user at that timestamp so no one can claim those rewards and rewards gets stuck in contract forever
Impact Details
loss of rewards at rewards distributor in the first epoch
References
Proof of Concept
function testLostRewardsFirstEpoch() public {
initializeVotingEscrow();
// assert alcx balance of rewards distributor is zero
uint256 distributorBalance = alcx.balanceOf(address(distributor));
assertEq(distributorBalance, 0);
// Fast forward 1/2 epoch
// create a lock
hevm.warp(block.timestamp + nextEpoch / 2);
hevm.roll(block.number + 1);
uint256 tokenId1 = createVeAlcx(admin, TOKEN_1, MAXTIME, false);
// Finish the epoch and distribute some rewards
hevm.warp(newEpoch());
voter.distribute();
// assert alcx balance of rewards distributor is greater than zero which means some tokens has been transffered as reward
uint256 distributorBalanceEnd = alcx.balanceOf(address(distributor));
assertGt(distributorBalanceEnd, 0);
// calculate claimable amount by token1
uint256 claimable1 = distributor.claimable(tokenId1);
// as we see token1 can't claim all alcx tokens despite that he's only user (on one can claim it)
assert(distributorBalanceEnd > claimable1);
// to ensure diffrence is high we check freezed amount is at least 3 time more than claimable amount
assert(distributorBalanceEnd > 3 * claimable1);
}
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 first epoch's reward allocation is based on a balance snapshot taken before the voting escrow contract had any users, leaving that share unclaimable.
Impact
A portion of the first epoch's rewards is permanently frozen in the distributor and cannot be claimed by anyone.
What the attacker needed
Deployment of distributor and escrow together; no users at first epoch boundary
How it was found
- Deploy the rewards distributor and voting escrow together, so no user exists at the first epoch boundary.
- Advance half an epoch and create a lock to get a veALCX token.
- Move to the next epoch and call distribute to send rewards to the distributor.
- Compare the distributor's balance with the claimable amount for the only token and observe the difference is unclaimable.
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 rewards contract pays out tokens based on who held voting tokens at the end of each period (an epoch). For the very first period, it looks at a moment before anyone had any voting tokens, so nobody qualifies for that slice of rewards. Those tokens stay locked in the contract with no way to withdraw them.
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.