Skip to content
Business logic Audit finding Beginner

Misconfiguration of Fees Incentive Might Cause Tokens To Be Stuck In Booster Contract

The Booster contract's setFeeInfo function lacks validation that the two fee incentive percentages sum to 100%. If misconfigured, only a fraction of collected fees is distributed, leaving the remainder stuck in the contract.

xiaoming90 Follow

Originally disclosed on Code4rena

Submitted by xiaoming90, also found by 0xNazgul, berndartmueller, cccz, FSchmoede, Funen, kirk-baird, Kumpa, and VAD37

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L193

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L576

Proof of Concept

The Booster.setFeeInfo function is responsible for setting the allocation of gauge fees between lockers and $VE3D stakers. lockFeesIncentive and stakerLockFeesIncentive should add up to 10000 , which is equivalent to 100%.

However, there is no validation check to ensure that that _lockFeesIncentive and _stakerLockFeesIncentive add up to 10000. Thus, it entirely depends on the developer to get these two values right.

As such, it is possible to set lockFeesIncentive + takerLockFeesIncentive to be less than 100%. This might happen due to human error. For instance, a typo (forget a few zero) or newly joined developer might not be aware of the fee denomination and called setFeeInfo(40, 60) instead of setFeeInfo(4000, 6000).

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L193

uint256 public constant FEE_DENOMINATOR = 10000;

// Set reward token and claim contract, get from Curve's registry
function setFeeInfo(uint256 _lockFeesIncentive, uint256 _stakerLockFeesIncentive) external {
    require(msg.sender == feeManager, "!auth");

    lockFeesIncentive = _lockFeesIncentive;
    stakerLockFeesIncentive = _stakerLockFeesIncentive;
    ..SNIP..
}

Assume that setFeeInfo(40, 60) is called instead of of setFeeInfo(4000, 6000), only 1% of the fee collected will be transferred to the users and the remaining 99% of the fee collected will be stuck in the Booster contract.

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L576

function earmarkFees() external returns (bool) {
    //claim fee rewards
    IStaker(staker).claimFees(feeDistro, feeToken);
    //send fee rewards to reward contract
    uint256 _balance = IERC20(feeToken).balanceOf(address(this));

    uint256 _lockFeesIncentive = _balance.mul(lockFeesIncentive).div(FEE_DENOMINATOR);
    uint256 _stakerLockFeesIncentive = _balance.mul(stakerLockFeesIncentive).div(
        FEE_DENOMINATOR
    );
    if (_lockFeesIncentive > 0) {
        IERC20(feeToken).safeTransfer(lockFees, _lockFeesIncentive);
        IRewards(lockFees).queueNewRewards(_lockFeesIncentive);
    }
    if (_stakerLockFeesIncentive > 0) {
        IERC20(feeToken).safeTransfer(stakerLockRewards, _stakerLockFeesIncentive);
        IRewards(stakerLockRewards).queueNewRewards(feeToken, _stakerLockFeesIncentive);
    }
    return true;
}

Can we retrieve or “save” the tokens stuck in Booster contract?

Any veAsset (e.g. CRV, ANGLE) sitting on the Booster contract is claimable. However, in this case, the feeToken is likely not a veAsset, thus the remaining gauge fee will be stuck in the Booster contract perpetually. For instance, in Curve, the gauge fee is paid out in 3CRV, the LP token for the TriPool. (Source)

Impact

Users will lost their gauge fee if this happens.

Recommended Mitigation Steps

Implement validation check to ensure that lockFeesIncentive and takerLockFeesIncentive add up to 100% to eliminate any risk of misconfiguration.

uint256 public constant FEE_DENOMINATOR = 10000;

// Set reward token and claim contract, get from Curve's registry
function setFeeInfo(uint256 _lockFeesIncentive, uint256 _stakerLockFeesIncentive) external {
    require(msg.sender == feeManager, "!auth");
    require(_lockFeesIncentive + _stakerLockFeesIncentive == FEE_DENOMINATOR, "Invalid fees");

    lockFeesIncentive = _lockFeesIncentive;
    stakerLockFeesIncentive = _stakerLockFeesIncentive;
    ..SNIP..
}

solvetony (veToken Finance) confirmed and commented:

Will try to provide a fix based on recommendation.

Alex the Entreprenerd (judge) commented:

The warden has shown that, due to a lack of checks, a misconfiguration can happen that will cause tokens to be stuck (although temporarily) in the Booster.

I believe a simple check to ensure:

  • Caller incentive is not unfairly high (e.g. 100%)
  • Total sums up to 100%

Would be a great way to give additional guarantees to the contract.

Agree with Medium Severity.


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

Impact

Users could lose their gauge fees if the misconfiguration occurs, as the undistributed portion remains stuck in the contract.

What the attacker needed

FeeManager calls setFeeInfo with incorrect values

The fix

The contract should be fixed by adding a validation check that the two fee incentives sum to 10000.

How it was found

  1. Call setFeeInfo with values that sum to less than 10000 (e.g., 40 and 60 instead of 4000 and 6000).
  2. Call earmarkFees to distribute fees according to the misconfigured percentages.
  3. Observe that only a small portion of fees is transferred to users, leaving the rest stuck in the Booster contract.

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.

Smart contracts often use numbers to represent percentages, like 10000 meaning 100%. This contract lets an admin set two fee shares but doesn't check they add up to 100%. If the admin makes a mistake, most fees get stuck in the contract instead of going to users.

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 xiaoming90

View all

122 more disclosed reports, best first.

More from veToken Finance 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.