Open c4-bot-8 opened 5 months ago
GalloDaSballo marked the issue as duplicate of #277
GalloDaSballo marked the issue as sufficient quality report
trust1995 marked the issue as selected for report
The bug class is imho valid as either liquidator will liquidate at a loss or protocol will be losing money to protect from bad debt over time.
Hi @trust1995,
Did this issue miss the satisfactory
tag?
Thanks!
Hi @trust1995,
Did this issue miss the
satisfactory
tag?Thanks!
I believe selected-for-report qualifies as satisfactory implicitly.
Hi @trust1995, Did this issue miss the
satisfactory
tag? Thanks!I believe selected-for-report qualifies as satisfactory implicitly.
Thanks for the quick response, sir.
For transparency and per conversation with the sponsors, see here for the Wise Lending team's mitigation.
Lines of code
https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L306-L330 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseCore.sol#L260-L263 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L1100-L1102 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L1104-L1106 https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L237-L270
Vulnerability details
Impact
The
Wise Lending
protocol allows users to borrow small positions. Even if the protocol has a minimum deposit (collateral) amount check to mitigate the small borrowing position from creating bad debt, this protection can be bypassed.With a small borrowing position, there is no incentive for a liquidator to liquidate the position, as the liquidation profit may not cover the liquidation cost (gas). As a result, small liquidable positions will not be liquidated, leaving bad debt to the protocol.
Proof of Concept
The protocol allows users to borrow small positions since no minimum borrowing amount is checked in the
WiseSecurity::checksBorrow()
.No minimum borrowing amount check
: https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L306-L330Even if the protocol has a minimum deposit (collateral) amount check in the
WiseCore::_checkDeposit()
to mitigate the small borrowing position from creating bad debt, this protection can be easily bypassed.The
WiseCore::_checkMinDepositValue()
is a core function that checks a minimum deposit (collateral) amount. By default, this deposit amount check would be overridden (disabled). Even though this deposit amount check will be enabled, this protection can be bypassed by withdrawing the deposited fund later since there is no minimum withdrawal amount check in theWiseSecurity::checksWithdraw()
.@1 -- Even if there is a minimum deposit amount check, this protection can be bypassed
: https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseCore.sol#L260-L263@2 -- By default, the minimum deposit amount check would be overridden (disabled)
: https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L1100-L1102@3 -- Even though the minimum deposit amount check will be enabled, this protection can be bypassed by withdrawing the deposited fund later
: https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L1104-L1106As you can see, there is no minimum withdrawal amount check in the
WiseSecurity::checksWithdraw()
. Hence, a user can deposit collateral at or above the minimum deposit amount (i.e.,minDepositEthValue
) and then withdraw the deposited fund to be under theminDepositEthValue
. Later, they can borrow a small amount with small collateral.With a small borrowing position (and small collateral), there is no incentive for a liquidator to liquidate the position, as the liquidation profit may not cover the liquidation cost (gas). As a result, small liquidable positions will not be liquidated, leaving bad debt to the protocol.
No minimum withdrawal amount check
: https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/WiseSecurity/WiseSecurity.sol#L237-L270Tools Used
Manual Review
Recommended Mitigation Steps
Implement the minimum borrowing amount check to limit the minimum size of borrowing positions.
Assessed type
Other