Submitted by Limbooo, also found by falconhoof, btk, 14si2o_Flint, wangxx2026, Silvermist, Aymen0909, shaka, jnforja, crypticdefense, erosjohn, 0xspryon, y0ng0p3 (1, 2), 0xDemon, and alix40
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L301-L309
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L312-L320
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L323-L326
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L329-L331
Protocols that try to integrate with Revert Lend, expectingV3Vaultto be ERC-4626 compliant, will multiple issues that may damage Revert Lends brand and limit Revert Lends growth in the market.
All official ERC-4626 requirements are on theirofficial page. Non-compliant methods are listed below along with why they are not compliant and coded POCs demonstrating the issues.
As specified in ERC-4626, bothmaxDepositandmaxMintmust return the maximum amount that would allow to be used and not cause a revert. Also, if the deposits or mints are disabled at current moment, it MUST return 0.
However, in bothV3Vault::maxDepositorV3Vault::maxMint returns the amount that causes a revert in deposit or mint. This is because they do not check if the amount exceeded the daily lend limit and if this is a case, it will cause a revert inside _deposit function (where it used in both deposit and mint):
Furthermore, when dailyLendIncreaseLimitLeft == 0 that means the deposits and mints are temporarily disabled, while bothV3Vault::maxDepositandV3Vault::maxMint could return amounts that is more than 0. Based on ERC4626 requirements, it MUST return 0 in this case.
To run the POC, copy-paste it intoV3Vault.t.sol:
As specified in ERC-4626, bothmaxWithdrawandmaxRedeemmust return the maximum amount that would allow to be transferred from owner and not cause a revert. Also, if the withdrawals or redemption are disabled at current moment, it MUST return 0.
However, in bothV3Vault::maxWithdraworV3Vault::maxRedeem returns the amount that causes a revert in withdraw or redeem. This is because they do not check if the amount exceeded the current available balance in the vault and if this is a case, it will cause a revert inside _withdraw function (where it used in both withdraw and redeem):
To run the POC, copy-paste it intoV3Vault.t.sol:
To address the non-compliance issues, the following changes are recommended:
The modified maxDeposit function now correctly calculates the maximum deposit amount by considering both the global lend limit and the daily lend increase limit. If the calculated maximum global deposit exceeds the daily lend increase limit, the function returns the daily lend increase limit to comply with ERC-4626 requirements.
Similarly, the modified maxMint ensures compliance with ERC-4626 by calculating the maximum mints amount for a given owner. It considers both the global lend limit and the daily lend increase limit as mentioned in maxDeposit.
The modified maxWithdraw function now correctly calculates the maximum withdrawal amount for a given owner. It ensures that the returned value does not exceed the available balance in the vault. If the available balance is greater than the owners balance, it returns the owners balance, otherwise it return the available balance to prevent potential reverts during withdrawal transactions. This adjustment aligns with ERC-4626 requirements by ensuring that withdrawals do not cause unexpected reverts and accurately reflect the available funds for withdrawal.
Similarly, the modified maxRedeem function ensures compliance with ERC-4626 by calculating the maximum redemption amount for a given owner. It considers both the owners balance and the available liquidity in the vault as mentioned in maxWithdraw.
kalinbas (Revert) confirmed
Revert mitigated:
Status: Mitigation Confirmed. Full details in the report from thank_you.
