52956 sc high state inconsistency in batched yield distribution leads to direct theft of user funds and protocol insolvency
Description
Brief/Intro
Vulnerability Details
function distributeYieldWithLimit(uint256 totalAmount, uint256 startIndex, uint256 limit) external {
// Step 1: Transfer entire yield amount only on first call
if (startIndex == 0) {
yToken.safeTransferFrom(msg.sender, address(this), totalAmount);
}
// Step 2: CRITICAL BUG - Recalculate total supply on EVERY call
uint256 effectiveTotalSupply = 0;
for (uint256 i = 0; i < totalHolders; i++) {
address holder = $.holders.at(i);
if (_isYieldAllowed(holder)) {
effectiveTotalSupply += balanceOf(holder); // Uses current balances!
}
}
// Step 3: Process batch using current supply calculation
for (uint256 i = startIndex; i < endIndex; i++) {
address holder = $.holders.at(i);
uint256 holderBalance = balanceOf(holder);
uint256 share = (totalAmount * holderBalance) / effectiveTotalSupply;
yToken.safeTransfer(holder, share);
}
}Impact Details
Link to Proof of Concept
Proof of Concept
Prerequisites
Notes
Previous52796 sc low whitelist restriction in arctoken blocks all minting and burningNext49787 sc high batched yield distribution doesn t account for transfers purchases between batches
Was this helpful?