validateVariablePoolHasEnoughLiquidity
will always fail causing complete DOS to the protocol
#244
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-218
🤖_10_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/CapsLibrary.sol#L68
Vulnerability details
Impact
buyCreditMarket
,sellCreditMarket
andliquidateWithReplacement
all callvalidateVariablePoolHasEnoughLiquidity
in the end of their execution to make sure that there is enough liquidity in the AAVE V3 pool. The issue is that the validation invalidateVariablePoolHasEnoughLiquidity
is critically wrong and will fail when used with the actual AAVE protocol.As a result borrowing and lending will be completely blocked.
Proof of Concept
Here is the validation performed in
validateVariablePoolHasEnoughLiquidity
:As we can see, the balance of the underlying borrow token (USDC) of the pool is derived as the balance of
address(state.data.variablePool)
. The issue is that AAVE stores the underlying tokens in the individualAToken
smart contracts, not thePool
contract. There are multiple ways we can understand this.Firstly, looking into the USDC balances of the
Pool
andAToken
contracts on Etherscan.Secondly, looking into the
supply
andwithdraw
functions on AAVE:1/ Pool.sol -> supply() -> SupplyLogic.executeSupply():
We can see in the
executeSupply
function, called insupply
, that the supplied underlying tokens are transferred directly from the sender (Size) to theAToken
contract.2/ Pool.sol -> withdraw() -> SupplyLogic.executeWithdraw():
Here we can see that no token transfers are occuring and the transfers are actually performed in the
AToken
contract (https://etherscan.io/address/0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c#readProxyContract), in theburn
function:As a result,
buyCreditMarket
,sellCreditMarket
will always fail when callingvalidateVariablePoolHasEnoughLiquidity
, and lending/borrowing will never work.Tools Used
Manual review
Recommended Mitigation Steps
In
validateVariablePoolHasEnoughLiquidity
, use theAToken
contract, not thePool
contract:Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: