Alcx rewards are permanently frozen when two to
When two voting-escrow tokens are merged, the source token is burned without first claiming its accrued ALCX rewards. The unclaimed rewards of the burned token become permanently frozen and can no longer be claimed.
- Disclosed after under an hour
31008 - [SC - High] Alcx rewards are permanently frozen when two to...
Submitted on May 10th 2024 at 19:51:14 UTC by @Adrianx for Boost | Alchemix
Report ID: #31008
Report type: Smart Contract
Report severity: High
Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/VotingEscrow.sol
Impacts:
- Permanent freezing of unclaimed yield
Description
Brief/Intro
Alcx rewards are not claimed before burning the merged token, which leads to a permanent freezing of unclaimed Alcx rewards.
Vulnerability Details
When two tokens are merged, the from token is burnt but the unclaimed alcx rewards of the from token are not claimed before burning it. This causes the unclaimed alcx rewards of the from token to be permanently frozen when the token is burnt.
IFluxToken(FLUX).mergeFlux(_from, _to);
// If max lock is enabled end is the max lock time, otherwise it is the greater of the two end times
uint256 end = _locked1.maxLockEnabled
? ((block.timestamp + MAXTIME) / WEEK) * WEEK
: _locked0.end >= _locked1.end
? _locked0.end
: _locked1.end;
locked[_from] = LockedBalance(0, 0, false, 0);
_checkpoint(_from, _locked0, LockedBalance(0, 0, false, 0));
_burn(_from, value0);
_depositFor(_to, value0, end, _locked1.maxLockEnabled, _locked1, DepositType.MERGE_TYPE);
As seen above, the alcx rewards are not claimed before burning the merged token. This leads to a permanent freezing of unclaimed rewards.
Impact Details
Alcx rewards are permanently frozen when the from tokens are burnt during token merging.
References
Proof of Concept
Add the test below to VotingEscrow.t.sol and check the logs to see the frozen rewards.
function testFrozenRewards() public {
uint256 tokenId1 = createVeAlcx(David, TOKEN_1, MAXTIME, false);
uint256 tokenId2 = createVeAlcx(David, TOKEN_100K, MAXTIME / 2, false);
hevm.startPrank(David);
uint256 lockEnd1 = veALCX.lockEnd(tokenId1);
assertEq(lockEnd1, ((block.timestamp + MAXTIME) / ONE_WEEK) * ONE_WEEK);
assertEq(veALCX.lockedAmount(tokenId1), TOKEN_1);
// Vote to trigger flux accrual
hevm.warp(newEpoch());
address[] memory pools = new address[](1);
pools[0] = alETHPool;
uint256[] memory weights = new uint256[](1);
weights[0] = 5000;
voter.vote(tokenId1, pools, weights, 0);
voter.vote(tokenId2, pools, weights, 0);
voter.distribute();
hevm.warp(newEpoch());
// Reset to allow merging of tokens
voter.reset(tokenId1);
voter.reset(tokenId2);
veALCX.merge(tokenId1, tokenId2);
uint256 frozenAlcxReward = distributor.claimable(tokenId1);
// The unclaimed rewards are permanently frozen
vm.expectRevert();
distributor.claim(tokenId1, false);
console.log("frozen AlcxReward", frozenAlcxReward);
assertEq(veALCX.ownerOf(tokenId1), address(0));
hevm.stopPrank();
}
frozen AlcxReward: 492146894738584492
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 merge routine burns the source token and clears its lock without calling the reward distributor to claim its pending ALCX first.
Impact
Unclaimed ALCX rewards on the source token are permanently frozen once it is burned during a merge.
What the attacker needed
Two locked positions owned by one user; rewards accrued via voting
How it was found
- Create two locked positions for the same user.
- Vote with both positions and distribute so rewards accrue.
- Reset both positions so they can be merged.
- Merge the first token into the second.
- Observe that claiming rewards for the burned token now reverts and the amount is frozen.
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 user locks tokens in a contract and earns rewards over time. When they combine two of their locked positions into one, the old position is deleted, but the rewards it had earned are never paid out first, so that money is lost for good.
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.