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.
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.
- If the fees are set at 1e18, the withdraw function won’t work as it will cause division by 0 error.
- 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
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
- Deploy a new Vault contract.
- Call initialize with fee values set to 2e18 for deposit, withdrawal, management, and performance.
- 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.