-
Notifications
You must be signed in to change notification settings - Fork 2
toshii - Protocol understates the value of user's collateral, which can lead to issues including premature liquidation #201
Comments
Escalate for 10 USD |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Agree with escalation. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
toshii
high
Protocol understates the value of user's collateral, which can lead to issues including premature liquidation
Summary
The protocol does not correctly calculate the value of a user's underlying collateral, which can lead to multiple issues, with the most prevalent being premature liquidation
Vulnerability Detail
Although the undervaluing of a user's collateral can lead to many issue with the protocol functionality, the most prevalent is the potential for premature liquidations, which will lead to unfair loss of user funds. Fundamentally the issue is that the value of a user's collateral includes the interest owed to that user for their collateral. However, the protocol does not correctly handle incorporating this interest. Let's see how.
When a user is being liquidated, another user will call
liquidate
. In this call, interest is first accrued tomarketBorrow
andmarketCollateral
. Then, a check is done to see if the borrower is liquidatable:The
_isLiquidatable
function loops over all the markets that the borrower has collateral in, and uses that to calculate the total value of the user's collateral:The
exchangeRate
value effectively converts a given amount of ibTokens that the user has to the underlying tokens. However, this value is only correct for a given market directly following a call to accrue interest for that market. The main issue arises because this function does not accrue interest to all of the markets that a user has collateral in prior to calculating the value of the user's tokens. This means that their total collateral value can be severely undervalued, especially if they have a lot of unaccounted for interest in markets that the liquidator is not liquidating collateral from.Impact
The protocol is in many cases undervaluing the collateral of a given user, which can lead to premature liquidation of that user and ultimately unfair loss of funds, even if they have enough collateral to cover their loan
Code Snippet
Referenced lines of code:
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/IronBank.sol#L499
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/IronBank.sol#L1082-L1086
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/IronBank.sol#L810
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/IronBank.sol#L919
Tool used
Manual Review
Recommendation
In the
_isLiquidatable
function, accrue interest to all markets which a user has collateral in prior to calculating theexchangeRate
for those markets.The text was updated successfully, but these errors were encountered: