Skip to content
Smart contracts Audit finding Intermediate

No function to recover the remained yield by distributeyieldwithlimit

The batched yield distribution function calculates each holder's share with integer division that floors the result, so the sum of all shares can be less than the total amount. The leftover yield stays in the contract with no function to recover it, and the completion event still reports the full amount as distributed.

ubl4nk Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52847 sc high no function to recover the remained yield by distributeyieldwithlimit

Submitted on Aug 13th 2025 at 15:43:57 UTC by @ubl4nk for Attackathon | Plume Network

Description

Brief / Intro

This vulnerability causes yield tokens to become permanently locked in the contract due to integer division rounding errors, with no direct mechanism to recover them. The impact is significant when yield tokens have high value (e.g., $1000 per token) or when distributions occur frequently (e.g., daily), leading to accumulating losses that can reach substantial amounts.

Vulnerability Details

  • distributeYieldWithLimit computes each holder's share as: (totalAmount * holderBalance) / effectiveTotalSupply Because Solidity integer division floors results, small rounding losses occur per-holder.
  • The non-batched distributeYield compensates by assigning the remainder to the last holder (e.g., lastShare = amount - distributedSum), preventing rounding loss. distributeYieldWithLimit lacks any such final adjustment.
  • Consequences:
    1. Locked funds: Cumulative rounding remainders cause totalAmount - amountDistributed to remain inside the contract with no direct recovery function.
    2. No recovery mechanism: Admin or other actors cannot reclaim the locked yield, even by changing batch parameters (totalAmount, startIndex, maxHolders).
    3. Misleading event: When nextIndex == 0, the function emits YieldDistributed(totalAmount, yieldTokenAddr), implying the full amount was distributed while some tokens may remain locked.
    4. Scalability: Frequent distributions or many holders amplify the problem as rounding errors accumulate.

Impact Details

A small amount becomes semi-locked in the contract and cannot be recovered directly, accumulating over time and potentially becoming significant.

Proof of Concept

Assumptions for PoC

  • Contract deployed with a yield token (ERC20-like).
  • Holders array: 3 holders (A, B, C) with balances of 10 tokens each.
  • Total supply: 30 tokens (effectiveTotalSupply = 30).
  • Yield amount: totalAmount = 100 (units of yield token).
  • Batch size: single batch with maxHolders = 3.
  • No restricted holders for simplicity.

{% stepper %} {% step %}

Setup

  • Holders:
    • A: balance = 10 (allowed)
    • B: balance = 10 (allowed)
    • C: balance = 10 (allowed)
  • totalHolders = 3
  • effectiveTotalSupply = 10 + 10 + 10 = 30
  • Caller (with YIELD_DISTRIBUTOR_ROLE) approves and calls: distributeYieldWithLimit(100, 0, 3)
  • Yield token transfer to contract: 100 units {% endstep %}

{% step %}

Execute Batch: distributeYieldWithLimit(100, 0, 3)

Batch holders: A, B, C (all allowed).

Calculations per holder (Solidity integer division floors):

  • For A:
    • share = (100 * 10) / 30 = 1000 / 30 ≈ 33.33 -> 33
    • Transfer 33 to A
  • For B:
    • share = (100 * 10) / 30 = 33
    • Transfer 33 to B
  • For C:
    • share = (100 * 10) / 30 = 33
    • Transfer 33 to C

Distributed sum:

  • amountDistributed = 33 + 33 + 33 = 99

Contract state after distribution:

  • nextIndex = 0 (endIndex = 3 = totalHolders)
  • Event emitted: YieldDistributed(100, yieldTokenAddr) — misleading because only 99 distributed
  • Remaining locked in contract: 100 - 99 = 1 {% endstep %} {% endstepper %}

Key Evidence / Link

The original report as published on Immunefi, by ubl4nk. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

Likely the batched distribution function floors each holder's share with integer division and, unlike the non-batched version, never assigns the accumulated remainder to a final recipient.

Impact

A small amount of yield becomes semi-locked in the contract and cannot be recovered, and this could accumulate to a significant sum with frequent distributions or many holders.

What the attacker needed

Caller holds the yield distributor role; yield token approved to the contract

How it was found

  1. Set up three holders with equal balances and a total supply of thirty.
  2. The distributor approves the yield token and calls the batched distribution with an amount of one hundred across all three holders.
  3. Each holder receives a floored share of thirty-three, so only ninety-nine is distributed.
  4. The remaining one unit stays locked in the contract while the event reports the full amount.

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.

When a contract splits an amount of tokens between many people, it does division that can only produce whole numbers, so small fractions get dropped. In this function the dropped fractions are never given to anyone and stay stuck in the contract forever. Over many payouts this small leftover can add up to a meaningful amount that nobody can withdraw.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by ubl4nk

View all

1 more disclosed report, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.