Skip to content
Business logic Audit finding Beginner

Vault fees can be set to anything when initializing

The vault's initialize function accepts any fee values without validation. If fees are set to 1e18 or higher, functions like withdraw can fail due to division by zero or arithmetic overflow.

aashar Follow with rbserver, Aymen0909 and 4 others

Originally disclosed on Code4rena

Submitted by aashar, also found by rbserver, Aymen0909, hashminer0725, 0xmuxyz, 7siech, and supernova

The vault owner can charge any fees when initializing. Because of this a lot of problems can occur.

  1. If the fees are set at 1e18, the withdraw function won’t work as it will cause division by 0 error.
  2. If all the fees are set beyond 1e18, many of the functions won’t work due to arithmetic overflow.

Proof of Concept

Below is the code where the fees can be set to anything during the initialization:

function initialize(
        IERC20 asset_,
        IERC4626 adapter_,
        VaultFees calldata fees_,
        address feeRecipient_,
        address owner
    ) external initializer {
       //code
        fees = fees_;
      // code

Here is a test to confirm the same:

function test_Vault_any_Fees() public{
    address vaultAddress1 = address(new Vault());
    Vault vault1;
    vault1 = Vault(vaultAddress1);
    vault1.initialize(
      IERC20(address(asset)),
      IERC4626(address(adapter)),
      VaultFees({ deposit: 2e18, withdrawal: 2e18, management: 2e18, performance: 2e18 }),
      feeRecipient,
      address(this)
    );
  }

Tools Used

Foundry tests

Recommended Mitigation Steps

Add a revert statement like this:

if (
            newFees.deposit >= 1e18 ||
            newFees.withdrawal >= 1e18 ||
            newFees.management >= 1e18 ||
            newFees.performance >= 1e18
        ) revert InvalidVaultFees();

RedVeil (Popcorn) confirmed, but disagreed with severity

LSDan (judge) decreased severity to Medium


The original report as published on Code4rena, by aashar. 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 initialize function assigns the provided fee values directly to storage without checking that each is less than 1e18.

Impact

If fees are set to 1e18, the withdraw function may fail due to division by zero; if set above 1e18, many functions may fail due to arithmetic overflow.

What the attacker needed

Ability to deploy a new Vault contract

The fix

The initialize function should revert if any fee is greater than or equal to 1e18.

How it was found

  1. Deploy a new Vault contract.
  2. Call initialize with fee values set to 2e18 for deposit, withdrawal, management, and performance.
  3. Observe that the transaction succeeds without reverting.

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 vault is a smart contract that holds and manages money. The owner can set fees when creating it, but the code doesn't check if the fees are too high. If fees are set to 100% or more, some actions like withdrawing money break because the maths goes wrong.

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 Popcorn 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.