52519 sc low missing eligibility check before fund transfer in distributeyield leads to permanent loss of yield tokens
Description
Brief / Intro
Vulnerability Details
function distributeYield(uint256 amount) external onlyRole(YIELD_DISTRIBUTOR_ROLE) nonReentrant {
// ... validation checks ...
// STEP 1: Transfer funds INTO contract (always executes)
ERC20Upgradeable yToken = ERC20Upgradeable(yieldTokenAddr);
yToken.safeTransferFrom(msg.sender, address(this), amount); // Line 435
// STEP 2: Calculate eligible holders
uint256 effectiveTotalSupply = 0;
for (uint256 i = 0; i < holderCount; i++) {
address holder = $.holders.at(i);
if (_isYieldAllowed(holder)) {
effectiveTotalSupply += balanceOf(holder);
}
}
// STEP 3: If no eligible holders, EXIT without distributing
if (effectiveTotalSupply == 0) {
emit YieldDistributed(0, yieldTokenAddr); // Line 449
return; // Funds already in contract, now trapped forever!
}
}Impact Details
Proof of Concept
References
Previous51988 sc medium plumerewardlogic calculaterewardswithcheckpointsview lacking of checking if the validator is inactive but not slashed Next51391 sc low enabletoken function overwrites amountsold to zero causing permanent loss of sales history
Was this helpful?