51090 sc high malicious user can steal yields when arctoken distributeyieldwithlimit is used
Description
Brief / Intro
Vulnerability Details
466 function distributeYieldWithLimit(
467 uint256 totalAmount,
468 uint256 startIndex,
469 uint256 maxHolders
470 )
...
510 uint256 effectiveTotalSupply = 0;
511 for (uint256 i = 0; i < totalHolders; i++) {
512 address holder = $.holders.at(i);
513 if (_isYieldAllowed(holder)) {
514 effectiveTotalSupply += balanceOf(holder); <<<<<<<<<<<< calculate the `effectiveTotalSupply`
515 }
516 }
...
530 for (uint256 i = 0; i < batchSize; i++) {
531 uint256 holderIndex = startIndex + i;
532 address holder = $.holders.at(holderIndex);
533
534 if (!_isYieldAllowed(holder)) {
535 continue;
536 }
537
538 uint256 holderBalance = balanceOf(holder);
539 if (holderBalance > 0) {
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< distribute yields based on balanceOf(holder)
540 uint256 share = (totalAmount * holderBalance) / effectiveTotalSupply;
541 if (share > 0) {
542 yToken.safeTransfer(holder, share);
543 amountDistributed += share;
544 }
545 }
546 }
...
554 return (nextIndex, totalHolders, amountDistributed);
555 }Impact Details
Proof of Concept
References
Previous52837 sc insight gas heavy repeated binary search increases reward calculation gas costsNext51567 sc low contract cannot be paused missing public pause and unpause functions
Was this helpful?