code4rena-2024-03-revert-lend-m14
[M-14] V3Vault is not ERC-4626 compliant
Summary
ERC4626을 따르는 Vault를 구현할 때, ERC4626에서 반드시 지키도록 명시한 스펙을 지키지 않았다. 이는 외부 통합을 깨지게 할 수 있다.
Keyword
erc4626
Vulnerability
ERC4626을 따르는 Vault를 구현할 때, ERC4626의 공식 페이지에서 정의한 반드시 따라야 하는 스펙을 지키지 않았다.
V3Vault::maxDeposit 와 V3Vault::maxMint
ERC4626::maxDeposit 에서 준수되지 않은 사항은 다음과 같다.
MUST return the maximum amount of assets deposit would allow to be deposited for receiver and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
MUST factor in both global and user-specific limits, like if deposits are entirely disabled (even temporarily) it MUST return 0.
ERC4626::maxMint 에서 준수되지 않은 사항은 다음과 같다.
MUST return the maximum amount of shares mint would allow to be deposited to receiver and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
MUST factor in both global and user-specific limits, like if mints are entirely disabled (even temporarily) it MUST return 0.
V3Vault::maxDeposit 와 V3Vault::maxMint는 모두 deposit 또는 mint를 호출했을 때 트랜잭션이 취소될 수 있는 금액을 반환한다. 이는 일일 대출 한도를 초과한 금액이 있는지 확인하지 않기 때문이다.
src/V3Vault.sol:
915: if (assets > dailyLendIncreaseLimitLeft) {
916: revert DailyLendIncreaseLimit();
917: } else {또한, dailyLendIncreaseLimitLeft == 0 로 설정되어 있다면 deposit 과 mint가 일시적으로 비활성화 됨을 의미하지만, V3Vault::maxDeposit 와 V3Vault::maxMint 는 0보다 큰 금액을 리턴할 수 있다. 이 경우 ERC4626 요구사항에 따라 0을 리턴해야 한다.
V3Vault::maxWithdraw 와 V3Vault::maxRedeem
ERC-4626에 명시된 대로 maxWithdraw와 maxRedeem은 모두 유저가 출금할 수 있는 최대 금액을 반환해야 하며, 해당 금액으로 withdraw 또는 redeem 호출 시 트랜잭션 취소가 발생하지 않아야 한다. 또한 현재 withdraw 또는 redeem이 비활성화되어 있는 경우 0을 반환해야 한다.
ERC4626::maxWithdraw 에서 준수되지 않은 사항은 다음과 같다.
MUST return the maximum amount of assets that could be transferred from owner through withdraw and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily) it MUST return 0.
ERC4626::maxRedeem 에서 준수되지 않은 사항은 다음과 같다.
MUST return the maximum amount of shares that could be transferred from owner through redeem and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
MUST factor in both global and user-specific limits, like if redemption is entirely disabled (even temporarily) it MUST return 0.
V3Vault::maxWithdraw 와 V3Vault::maxRedeem 는 withdraw 또는 redeem 을 호출했을 때 트랜잭션이 취소될 수 있는 금액을 리턴한다. 이는 해당 금액이 금고의 현재 사용 가능한 잔액을 초과했는지 확인하지 않기 때문이다.
src/V3Vault.sol:
962: (, uint256 available,) = _getAvailableBalance(newDebtExchangeRateX96, newLendExchangeRateX96);
963: if (available < assets) {
964: revert InsufficientLiquidity();
965: }Impact
외부 통합을 깨지게 할 수 있다.
Mitigation
ERC4626 스펙을 지키도록 한다.
tags: bughunting, revert lend, smart contract, solidity, erc4626, severity medium