The LendingPool contract contains a vulnerability in its lending and liquidation mechanisms, where collateral is significantly undervalued compared to the borrowed amount. This flaw allows a borrower to trigger an immediate liquidation event by borrowing more than their collateral value, leading to potential exploits and financial losses.
In the lending pool contract, the LendingPool::borrow() function does not correctly account for the necessary collateral-to-loan ratio. Specifically, a user can borrow an amount (e.g., 125 ether) that exceeds their collateral's current value (100 ether). After borrowing, the contract allows the user to immediately initiate liquidation without any protective checks. This results in the liquidation being triggered by the user themselves, even when their position is not in a valid state for liquidation.
Collateral value: 100 ether
Borrowed amount: 125 ether
Collateral-to-loan ratio: 80%
Liquidation threshold: 100% (borrow amount exceeding collateral)
The vulnerability exists because the contract does not enforce a proper collateralization ratio before allowing a user to borrow funds. Moreover, the liquidation process can be initiated immediately after borrowing, even if the contract has not been updated with the correct collateral-to-debt ratio.
The impact of this vulnerability can result in:
Immediate liquidation with excessive borrowing: Borrowing more than the collateral without triggering any safeguards can lead to an automatic liquidation event.
Loss of funds: The borrower can exploit the system by borrowing more than what they can afford to repay, causing the system to liquidate their position unfairly.
Financial instability: Other users of the lending pool may be at risk due to the unbalanced collateralization, as the system could lose funds in case of an exploit.
If an attacker or user is able to exploit this vulnerability, they may:
Borrow funds that they cannot repay.
Trigger liquidation that results in the loss of collateral or funds.
Manipulate the contract to enrich themselves at the expense of other users.
PoC
Manual code review
Collateral-to-loan ratio check: Add a check to ensure that the collateralization ratio is always above the liquidation threshold before allowing a user to borrow funds. This can be done by comparing the collateral value to the amount borrowed and ensuring the value exceeds the required ratio (e.g., 150% collateral for every 100% loan).
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.