ALCX rewards arent claimed for from token when
When merging two voting-escrow tokens, the protocol burns the 'from' token without first claiming its accrued ALCX rewards. Those unclaimed rewards become permanently stuck because the rewards distributor's claim function reverts once the token no longer exists.
- Disclosed after under an hour
31435 - [SC - High] ALCX rewards arent claimed for from token when ...
Submitted on May 19th 2024 at 02:47:23 UTC by @OxAlix2 for Boost | Alchemix
Report ID: #31435
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
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
In VotingEscrow::withdraw, the protocol is claiming the ALCX rewards before burning the token, which makes sense as the token will be burnt. However, this is not done when merging 2 tokens, this puts the ALCX rewards of the "from" token at risk of being stuck forever.
Vulnerability Details
When merging 2 tokens, token_1, and token_2, assume that token_1 has some unclaimed ALCX rewards, through the merge process token_1 will be burnt. So all these unclaimed ALCX will remain stuck forever as RewardsDistributor::claim will revert on the following:
require(approvedOrOwner || isVotingEscrow, "not approved");
because the token doesn't exist anymore.
Impact Details
ALCX rewards that were accumulated for the "from" token will remain unclaimable/stuck forever after the merge process.
References
https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/VotingEscrow.sol#L618-L651
Mitigation
Add the following in VotingEscrow::merge:
IRewardsDistributor(distributor).claim(_from, false);
Proof of concept
function testALCXRewardsNotClaimedOnMerge() public {
uint256 tokenId1 = createVeAlcx(admin, TOKEN_1, MAXTIME, false);
uint256 tokenId2 = createVeAlcx(admin, TOKEN_1, MAXTIME, false);
hevm.warp(minter.activePeriod() + nextEpoch);
voter.distribute();
assertGt(distributor.claimable(tokenId1), 0);
assertGt(distributor.claimable(tokenId2), 0);
hevm.prank(admin);
veALCX.merge(tokenId1, tokenId2);
assertGt(distributor.claimable(tokenId1), 0);
assertGt(distributor.claimable(tokenId2), 0);
vm.prank(admin);
vm.expectRevert(abi.encodePacked("not approved"));
distributor.claim(tokenId1, false);
}
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
The merge function burns the 'from' token without first claiming its pending ALCX rewards, unlike the withdraw function which does claim before burning.
What the attacker needed
Two voting-escrow tokens owned by the same user; unclaimed ALCX rewards on the 'from' token
The fix
The merge function should claim the 'from' token's rewards before burning it, as the withdraw function does.
How it was found
- Create two voting-escrow tokens for the same owner.
- Advance time and distribute rewards so both tokens have claimable ALCX.
- Merge the first token into the second.
- Attempt to claim rewards for the first token and observe the revert.
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 voting-escrow token is a receipt for locked tokens that earns rewards over time. When two such tokens are merged, the old 'from' token is destroyed, but any rewards it had earned are not paid out first. Because the rewards system checks that the token still exists, those rewards can never be claimed afterwards.
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.