Skip to content
Business logic Audit finding Intermediate

Users' voting weight can be double-counted when finalize epoch is processed in multiple steps

The epoch finalisation routine reads each voter's current token balance instead of a fixed snapshot, so a voter can move their stake between two addresses that are tallied in separate batches and have the same tokens counted twice. This lets a malicious actor inflate the voting weight of their chosen option and manipulate the outcome of the vote.

blockace Follow with cergyk

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-bmx-deli-swap-judging/issues/62

Found by

blockace, cergyk

Description

In Voter.sol, the admin can call finalizeEpoch in order to tally all of the votes when an epoch has ended. Since the list of voters can be unbounded, finalizing can be broken into multiple steps in order to avoid DOS by OOG.

Unfortunately, when tallying the votes, the current balance of SBF_BMX is used, which allows a manipulation of the result by malicious actors:

Voter.sol#L338-L369:

Solidity
    /// @dev Processes up to `maxBatch` auto-voters for `ep`, adding live balances to option weights.
    function _tallyAutoVotes(uint256 ep, uint256 maxBatch) internal returns (bool finished) {
        EpochData storage e = epochInfo[ep];
        uint256 processed;
        while (processed < maxBatch && batchCursor[ep] < autoVoterList.length) {
            uint256 i = batchCursor[ep];
            address voterAddr = autoVoterList[i];
            batchCursor[ep] = i + 1;
            processed++;

            uint8 opt = autoOption[voterAddr];
            if (opt >= 3) continue; // disabled
            if (userVoteWeight[ep][voterAddr] > 0) continue;


            //@audit current balance is used for voterAddr
>>          uint256 bal = SBF_BMX.balanceOf(voterAddr);
            if (bal == 0) {
                // queue for removal instead of removing now
                pendingRemovals[ep].push(voterAddr);
                continue;
            }
            e.optionWeight[opt] += bal;
            userVoteWeight[ep][voterAddr] = bal;
            userChoice[ep][voterAddr] = opt;
        }


        finished = (batchCursor[ep] >= autoVoterList.length);


        // process removals only after loop is complete
        if (finished && pendingRemovals[ep].length > 0) {
            _processPendingRemovals(ep);
        }
    }

Concrete scenario

The admin separates the processing of autoVotes into 2 transactions, and Alice controls 2 addresses voterAddressA (included in the first batch) and voterAddressB (included in the second batch).

Between the 2 admin transactions, Alice unstakes her sbfBMX from voterAddressA and stakes to voterAddressB.

Since the balance of sbfBMX at the time of admin calling is used, the sbfBMX from voterAddressA will be counted again when voterAddressB is processed during the second admin call.

Alice has successfully manipulated the result of the vote.

Recommendation

Either restrict staking of sBMX when finalizationInProgress, or use a snapshotting system which would get the latest userVoteWeight[prevEp][voterAddr] where prevEp is the latest epoch where userVoteWeight was updated.

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

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 tally reads the live token balance of each voter at processing time rather than a balance snapshot taken when the epoch ended, so stake moved between batches is counted more than once.

Impact

A malicious actor could double-count their voting weight and manipulate the result of the vote, provided the admin finalises the epoch in more than one step.

What the attacker needed

Admin finalises epoch in multiple steps; attacker controls two addresses; attacker can move stake between batches

The fix

Staking should be blocked while finalisation is in progress, or the tally should use a snapshot of each voter's weight from the last epoch in which it was recorded.

How it was found

  1. The admin splits finalisation of the epoch into two separate transactions.
  2. Alice holds stake under one address that falls in the first batch and another address in the second batch.
  3. Between the two admin transactions, Alice unstakes from the first address and stakes the same tokens to the second address.
  4. When the second batch is processed, the moved tokens are counted again for the second address.

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 vote is meant to count how many tokens each person holds at a fixed moment. Here the contract checks the balance at the moment each address is processed, and processing happens in several chunks. If someone moves their tokens from one address to another between chunks, the same tokens get counted for both addresses, so their vote counts twice.

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 blockace

View all

3 more disclosed reports, best first.

More from BMX Deli Swap

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.