30651 - [SC - Critical] Insolvency in RevenueHandlersol because unclaim...
Submitted on May 3rd 2024 at 02:32:14 UTC by @Django for Boost | Alchemix
Report ID: #30651
Report type: Smart Contract
Report severity: Critical
Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RevenueHandler.sol
Impacts:
Protocol insolvency
Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
The RevenueHandler.sol
contract accepts the repayments from the Alchemix protocol and splits it to users based on their locked VE positions. However, this contract will eventually reach a state of insolvency because unclaimed revenue is counted as new revenue for each newly-checkpointed epoch. Users will have a cumulative higher claimable balance than token balance in the contract.
Vulnerability Details
The Revenue Handler contract has a checkpoint()
function that must be called once at the beginning of each epoch (every 2 weeks). This functions takes the revenue obtained from the previous period and allots it to users based on the contract's token balances.
The issue arises due to the fact that previously-allotted and unclaimed revenue will still count toward these token balances, double-counting them for allotment.
This line double accounts for previously-unclaimed revenue.
uint256 thisBalance = IERC20(token).balanceOf(address(this));
Then the users are able to claim their portion of the claimable revenue based on the _claimable()
function which directly referrenced the epochRevenues
mapping that has already double-counted.
Impact Details
Insolvency due to users being able to claim more than the contract's token balance
Early claimers will be able to claim more than the last claimers, who will not be able to claim anything.
Output from POC
This POC simply sets up a token position, accrues revenue and checkpoints once, waits another epoch period, and checkpoints again. Since the user never claimed, the claimable revenue is doubled even though no new revenue was accrued.
Proof of Concept
Last updated