Open c4-bot-4 opened 8 months ago
0xEVom marked the issue as sufficient quality report
0xEVom marked the issue as primary issue
Likely low severity as non-zero minLoanSize
also protects from this and the attacker needs to hold a loan against all collateral in the vault for an extended period of time.
kalinbas (sponsor) acknowledged
kalinbas marked the issue as disagree with severity
Low severity
A very valuable exploitation path, but the conditions are too fringe. We can assume for argument's sake that minLoanSize = 0 is possible, but it is unlikely to reach the condition where the asset falls by 34% in an initialization scenario.
I am inclined to keep it at M. However, the impact of a DOS on such an initialized vault is insufficient, so I am temporarily marking it as low. I hope the warden can submit a PoC related to an inflationary attack, such as using inflation to manipulate the rate and steal loan asset.
jhsagd76 changed the severity to QA (Quality Assurance)
jhsagd76 marked the issue as grade-a
Planning to upgrade to M, due to the potential inflation attack during the vault cold start phase, seeking the sponsor's opinion.
I see that an attacker being the only borrower with a very small position for a certain amount of time (the collateral has to change value in this time significantly) could in theory cause the position to be underwater and then cause the lendExchangeRateX96 to become a small number. But if its a very small position, there will be other positions. So in theory i agree with the attack, but it is not practical. Thats why we acknowlegde it.
But would call it a low risk
Lines of code
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L1137
Vulnerability details
Impact
The function
_handleReserveLiquidation
will attempt to use lender deposits to socialize the costs of any bad debt that the protocol can incur, if there is not sufficient reserves left.The function does this by updating the share/asset conversion rate for the lenders:
Here,
missing
is the amount that cannot be covered from the reserves. Ifmissing
is exactly equal tototalLent
, then the new exchange will become zero.The exchange rate is updated only in this function and in
_calculateGlobalInterest
. The latter computes the new exchange rate as a function of the old, viaold + old * k
computation, so once the rate becomes zero, it can never become anything else again. Zero exchange rate will effectively prevent any futher deposits to the vault, as well as any other operations.An attacker can attemp to force this situation to occur by exploiting rouding errors. For example, they can deposit a Uniswap v3 positin worth 3 wei as a collateral and borrow 2 wei. If the price of the collateral drops sufficiently (more than 1/3) they can self-liquidate the loan, forcing the
newLendExchangeRateX96
to become zero.It is possible a similar attack could also be used to force
newLendExchangeRateX96
to become a very small positive number. Then the vault would become vulnerable to share inflation attack, allowing the attacker to steal from subsequent depositors.Proof of Concept
Output:
Tools Used
Manual review
Recommended Mitigation Steps
Revert liquidations if they would result in zero or very small value of
newLendExchangeRateX96
.Assessed type
Other