Skip to content
Business logic Audit finding Intermediate

DistributeYield can be frontrun to sandwich rewards. We can force ourselves to be the last holder and get unfairly big bonuses

The yield distribution function pays the last holder in its list the entire remainder of the reward pool, including rounding leftovers and shares that ineligible holders did not receive. An attacker could front-run a distribution, become the last holder, and collect an unfairly large bonus.

valkvalue Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

53038 sc low distributeyield can be frontrun to sandwich rewards we can force ourselves to be the last holder and get unfairly big bonuses

Submitted on Aug 14th 2025 at 17:50:12 UTC by @valkvalue for Attackathon | Plume Network

Description

Brief/Intro

distributeYield can be frontrun to sandwich rewards; an adversary can force themselves to be the last holder which would give them an unfairly large bonus.

Vulnerability Details

The current distributeYield implementation for ArcToken allows an adversary to sandwich rewards by becoming a holder of the token immediately before yield is distributed. The adversary can also aim to be the last holder, since the last holder receives any leftover funds that were not distributed due to some other holders being ineligible for yield.

Relevant excerpt:

Solidity
    function distributeYield(
        uint256 amount
    ) external onlyRole(YIELD_DISTRIBUTOR_ROLE) nonReentrant {

......
        ERC20Upgradeable yToken = ERC20Upgradeable(yieldTokenAddr);
        yToken.safeTransferFrom(msg.sender, address(this), amount);

        uint256 distributedSum = 0;
        uint256 holderCount = $.holders.length();
        if (holderCount == 0) {
            emit YieldDistributed(0, yieldTokenAddr);
            return;
        }

        uint256 effectiveTotalSupply = 0;
        for (uint256 i = 0; i < holderCount; i++) {
            address holder = $.holders.at(i);
            if (_isYieldAllowed(holder)) {
                effectiveTotalSupply += balanceOf(holder);
            }
        }

        if (effectiveTotalSupply == 0) {
            emit YieldDistributed(0, yieldTokenAddr);
            return;
        }

        uint256 lastProcessedIndex = holderCount > 0 ? holderCount - 1 : 0;
        for (uint256 i = 0; i < lastProcessedIndex; i++) {
            address holder = $.holders.at(i);

            if (!_isYieldAllowed(holder)) {
                continue;
            }

            uint256 holderBalance = balanceOf(holder);
            if (holderBalance > 0) {
                uint256 share = (amount * holderBalance) / effectiveTotalSupply;
                if (share > 0) {
                    yToken.safeTransfer(holder, share);
                    distributedSum += share;
                }
            }
        }

        if (holderCount > 0) {
            address lastHolder = $.holders.at(lastProcessedIndex);
            if (_isYieldAllowed(lastHolder)) {
                uint256 lastShare = amount - distributedSum;
                if (lastShare > 0) {
                    yToken.safeTransfer(lastHolder, lastShare);
                    distributedSum += lastShare;
                }
            }
        }

    }

Because the final share is computed as the remainder (amount - distributedSum) and sent to the last holder in the holders list, an adversary who ensures they are the last holder when distributeYield runs will receive any rounding leftovers plus any undistributed portions caused by ineligible holders.

To become the last holder:

  • Acquire tokens from the market or transfer tokens to a fresh address you control, which will be appended to the holders set/list by the contract's _update() logic.

Impact Details

{% hint style="warning" %} The vulnerability enables theft of unclaimed yield by front-running or sandwiching the distributeYield operation. The attacker may receive an outsized share by ensuring they are the last processed holder. {% endhint %}

References

Proof of Concept

{% stepper %} {% step %}

Step 1 — Observe distribution

An oracle or mempool watcher sees a pending distributeYield transaction submitted by an account with YIELD_DISTRIBUTOR_ROLE. {% endstep %}

{% step %}

Step 2 — Become a holder (front-run)

Before the distributeYield transaction is mined, acquire some ArcToken (from market or by transferring to a fresh address you control). The contract will add the new address to the holders list via _update(). {% endstep %}

{% step %}

Step 3 — Optionally ensure you are the last holder

If necessary, create a fresh address and transfer tokens to it as the final transaction before the distributor’s distributeYield executes, making that fresh address the last entry in the holders set/list. {% endstep %}

{% step %}

Step 4 — Distributor executes

When distributeYield runs, the function calculates shares for all but the last holder using eligible balances and sends each computed share. The last holder receives amount - distributedSum, which includes any leftover or undistributed portions resulting from ineligible holders or rounding. {% endstep %} {% endstepper %}

Notes

  • The PoC demonstrates how typical mempool front-running or sandwiching can be used to exploit the remainder logic that favors the last holder.
  • Links above are preserved as in the original report.

The original report as published on Immunefi, by valkvalue. 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 final holder's share is computed as the whole remaining amount rather than their proportional balance, so rounding leftovers and ineligible holders' shares all accrue to whoever is last in the list.

Impact

An attacker could steal unclaimed yield by front-running or sandwiching the distribution and receiving an outsized share as the last processed holder.

What the attacker needed

Ability to watch the mempool; tokens to acquire or transfer; a distribution is pending

The fix

The distribution should calculate each holder's share proportionally and handle rounding explicitly rather than handing the entire remainder to the last holder.

How it was found

  1. Watch the mempool for a pending distributeYield transaction from the yield distributor.
  2. Before it is mined, acquire tokens or transfer them to a fresh address so the contract adds it to the holders list.
  3. If needed, make a fresh address the final entry by transferring tokens to it just before the distribution runs.
  4. When distributeYield executes, the last holder receives the remaining amount, including leftovers and undistributed shares.

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.

A token contract shares out rewards among its holders. Instead of calculating every holder's share exactly, it pays everyone except the last holder normally, then gives whatever is left to the last holder. Someone who watches pending transactions can quickly buy or move tokens so they are that last holder, and walk away with extra money meant for others.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by valkvalue

View all

5 more disclosed reports, 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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.