Debt repaying can be temporary disabled by the owner of the LendingPool
contract, however finalizing liquidations are not disabled during this period. As a result, users' positions can accumulate more borrow interest, go above the liquidation threshold, and be liquidated, while users aren't able to repay the debts.
The owner of the LendingPool
contract can pause different functions of the contract, including repayments:
As a result, when repayments are disabled, the StabilityPool
can liquidate any position where a liquidation has been initialized and after the desired grace period, borrowers won't be able to protect against that by repaying their debts. Thus, borrowers will be forced to lose their collateral.
It's worth to mention that no new liquidations can be initiated, so this finding assumes that a Liquidation has been initialized before the contract owner pauses the operations.
However the finalizeLiquidation
function doesn't have the whenNotPaused
modifier applied, meaning that this can still be called by the StabilityPool to execute any valid liquidation:
This test assumes that the issue in the StabilityPool::liquidateBorrower() function for the approval has been fixed (see issue: "StabilityPool can't liquidate positions because of wrong user debt amount being approved causing the transaction to fail")
For the purpose of this test I modified the function to approve type(uint256).max. This shouldn't be done in production and there is already a recommendation in the issue mentioned above.
Update Line 461 in the liquidateBorrower() function :
function liquidateBorrower(address userAddress) external onlyManagerOrOwner nonReentrant whenNotPaused {- bool approveSuccess = crvUSDToken.approve(address(lendingPool), scaledUserDebt);+ bool approveSuccess = crvUSDToken.approve(address(lendingPool), type(uint256).max);}
In order to run the test you need to:
Run foundryup
to get the latest version of Foundry
Install hardhat-foundry: npm install --save-dev @nomicfoundation/hardhat-foundry
Import it in your Hardhat config: require("@nomicfoundation/hardhat-foundry");
Make sure you've set the BASE_RPC_URL
in the .env
file or comment out the forking
option in the hardhat config.
Run npx hardhat init-foundry
There is one file in the test folder that will throw an error during compilation so rename the file in test/unit/libraries/ReserveLibraryMock.sol
to => ReserveLibraryMock.sol_broken
so it doesn't get compiled anymore (we don't need it anyways).
Create a new folder test/foundry
Paste the below code into a new test file i.e.: FoundryTest.t.sol
Run the test: forge test --mc FoundryTest -vvvv
This would unfairly prevent Borrowers from making their repayments while still allowing the StabilityPool to liquidate them.
Foundry
Manual Review
Consider disallowing liquidations when repayments are disabled by adding the whenNotPaused
modifier to the finalizeLiquidation
function. Alternatively, consider never disallowing repayments so that users could maintain their positions in a healthy risk range anytime.
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.