Skip to content
Business logic Audit finding Intermediate

When MIN_VOTING_POWER_REQUIRED is changed, previous votes are not affected

When the minimum voting power threshold is changed, previously cast votes are not re-evaluated, so token IDs with voting power below the new threshold can still have their old votes counted. An attacker could exploit this to retain influence from spam or low-power votes after the threshold is raised.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

When MIN_VOTING_POWER_REQUIRED is changed, tokenIDs with votes lower than MIN_VOTING_POWER_REQUIRED will not be able to vote through the delegate function, but previous votes will not be affected. Since MIN_VOTING_POWER_REQUIRED is mainly used to reduce the influence of spam users, changing this value should affect previous votes.

Proof of Concept

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/vote-escrow/VoteEscrowDelegation.sol#L168-L194

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/vote-escrow/VoteEscrowDelegation.sol#L260-L262

https://github.com/code-423n4/2022-07-golom/blob/e5efa8f9d6dda92a90b8b2c4902320acf0c26816/contracts/vote-escrow/VoteEscrowDelegation.sol#L73-L74

Recommended Mitigation Steps

In the getPriorVotes and getVotes functions, when the balance corresponding to tokenId is less than MINVOTINGPOWER_REQUIRED, the value of votes will not be increased

    function getVotes(uint256 tokenId) external view returns (uint256) {
        uint256[] memory delegated = _getCurrentDelegated(tokenId);
        uint256 votes = 0;
        for (uint256 index = 0; index < delegated.length; index++) {
+         if(this.balanceOfNFT(delegated[index]) >= MIN_VOTING_POWER_REQUIRED){
            votes = votes + this.balanceOfNFT(delegated[index]);
+       }
        }
        return votes;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param tokenId The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorVotes(uint256 tokenId, uint256 blockNumber) public view returns (uint256) {
        require(blockNumber < block.number, 'VEDelegation: not yet determined');
        uint256[] memory delegatednft = _getPriorDelegated(tokenId, blockNumber);
        uint256 votes = 0;
        for (uint256 index = 0; index < delegatednft.length; index++) {
+         if(this.balanceOfAtNFT(delegatednft[index], blockNumber) >= MIN_VOTING_POWER_REQUIRED){
            votes = votes + this.balanceOfAtNFT(delegatednft[index], blockNumber);
+         }
        }
        return votes;
    }

zeroexdead (Golom) confirmed, but disagreed with severity

zeroexdead (Golom) commented:

When calling we getVotes() and getPriorVotes() we’re considering MIN_VOTING_POWER_REQUIRED. Reference: https://github.com/golom-protocol/contracts/commit/db650729b0805ec19906a0ea11de6af7a53ac382

0xsaruman (Golom) resolved

LSDan (judge) decreased severity to Medium and commented:

Downgrading this to medium. Assets are not at direct risk.


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

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 vote-counting functions (getVotes and getPriorVotes) do not check the minimum voting power threshold when summing delegated balances, so the threshold only applies at the time of delegation, not to existing votes.

Impact

Previous votes from token IDs below the new minimum voting power remain counted, so the threshold change does not reduce the influence of spam users as intended; assets are not at direct risk.

What the attacker needed

MIN_VOTING_POWER_REQUIRED is changed; attacker has delegated votes below the new threshold

The fix

The getVotes and getPriorVotes functions should skip delegated balances below MIN_VOTING_POWER_REQUIRED when summing votes, and the project later added such checks.

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.

In this voting system, a minimum amount of voting power is required to cast a vote. The report says that if the minimum is increased later, votes that were already cast by accounts below the new minimum are still counted. This means the rule change does not apply to past votes, which could let low-power accounts keep influence they should have lost.

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 cccz

View all

104 more disclosed reports, best first.

More from Golom contest

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.