Supply function doesn’t account for market maxDeposit when providing assets to it
The Silo vault's supply function ignored each underlying market's maxDeposit limit, so a deposit that could be spread across multiple vaults would instead revert when the first vault's cap was exceeded. An attacker could not steal funds, but legitimate users could be blocked from depositing.
SpicyMeatball Follow with 056Security, d3e4 and 3 others
Originally disclosed on Code4rena
Submitted by SpicyMeatball, also found by 056Security, d3e4, DanielArmstrong, Dulgiq, and Rampage
Finding description and impact
Some vaults that the Silo vault deposits into have their own supply caps (do not confuse with config[market].cap), which may prevent _supplyERC4626 from fully depositing user-provided assets. If these caps are not accounted for, the deposit function may revert instead of distributing assets across multiple vaults.
Proof of Concept
Consider a scenario where there are two vaults available for deposits:
- Vault 1 has a supply cap of 10,000 assets and currently holds 5,000, meaning
vault1.maxDepositis 10,000 - 5,000 = 5,000. - Vault 2 is in the same condition.
In total, 10,000 assets of deposit space are available. However, if a user tries to deposit 10,000 assets through the Silo vault, _supplyERC4626 is called:
function _supplyERC4626(uint256 _assets) internal virtual {
for (uint256 i; i < supplyQueue.length; ++i) {
IERC4626 market = supplyQueue[i];
uint256 supplyCap = config[market].cap;
if (supplyCap == 0) continue;
// Update internal balance for market to include interest if any.
// `supplyAssets` needs to be rounded up for `toSupply` to be rounded down.
uint256 supplyAssets = _updateInternalBalanceForMarket(market);
uint256 toSupply = UtilsLib.min(UtilsLib.zeroFloorSub(supplyCap, supplyAssets), _assets);
if (toSupply != 0) {
uint256 newBalance = balanceTracker[market] + toSupply;
// As `_supplyBalance` reads the balance directly from the market,
// we have additional check to ensure that the market did not report wrong supply.
if (newBalance <= supplyCap) {
// Using try/catch to skip markets that revert.
>> try market.deposit(toSupply, address(this)) {
_assets -= toSupply;
balanceTracker[market] = newBalance;
} catch {}
}
}
if (_assets == 0) return;
}
The function will first attempt to deposit 10,000 assets into Vault 1, but since vault1.maxDeposit < 10,000, the transaction will revert. The same issue occurs with Vault 2, causing the entire deposit operation to fail—even though sufficient space exists across both vaults.
Recommended mitigation steps
To avoid this issue, the function should check market.maxDeposit before attempting a deposit, similar to how it is handled in the _maxDeposit function:
function _maxDeposit() internal view virtual returns (uint256 totalSuppliable) {
for (uint256 i; i < supplyQueue.length; ++i) {
IERC4626 market = supplyQueue[i];
uint256 supplyCap = config[market].cap;
if (supplyCap == 0) continue;
(uint256 assets, ) = _supplyBalance(market);
>> uint256 depositMax = market.maxDeposit(address(this));
>> uint256 suppliable = Math.min(depositMax, UtilsLib.zeroFloorSub(supplyCap, assets));
In the _supplyERC4626 function:
function _supplyERC4626(uint256 _assets) internal virtual {
for (uint256 i; i < supplyQueue.length; ++i) {
IERC4626 market = supplyQueue[i];
uint256 supplyCap = config[market].cap;
if (supplyCap == 0) continue;
// Update internal balance for market to include interest if any.
// `supplyAssets` needs to be rounded up for `toSupply` to be rounded down.
uint256 supplyAssets = _updateInternalBalanceForMarket(market);
uint256 toSupply = UtilsLib.min(UtilsLib.zeroFloorSub(supplyCap, supplyAssets), _assets);
+ toSupply = Math.min(market.maxDeposit(address(this), toSupply));
With this fix, the Silo vault will distribute deposits correctly:
- 5,000 assets will be deposited into Vault 1.
- 5,000 assets will be deposited into Vault 2.
This prevents unnecessary reverts and ensures that all available deposit space is properly utilized.
IhorSF (Silo Finance) confirmed
This PR here accounts for
MaxDepositwhen completing a deposit
Status: Mitigation confirmed. Full details in reports from d3e4, t0x1c, and Drynooo.
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
Likely the supply function only checked the vault's own configured cap and did not check the underlying market's maxDeposit before calling deposit.
Impact
Legitimate deposits could revert even when enough total space exists across multiple vaults, blocking users from depositing.
What the attacker needed
Multiple vaults with supply caps; deposit amount exceeds first vault's remaining cap
How it was found
- Have two vaults each with a supply cap of 10,000 assets and each currently holding 5,000 assets.
- Attempt to deposit 10,000 assets through the Silo vault.
- The function tries to deposit all 10,000 into the first vault, which exceeds its maxDeposit of 5,000, so the call reverts.
- The same happens with the second vault, causing the entire deposit to fail.
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 pools money and puts it into other vaults. Each of those other vaults has a limit on how much it will accept. The main vault tried to put all the money into the first vault without checking that limit, so the whole deposit failed even though there was enough room across several vaults.
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.