Summary
The function LendingPool::repay()
only allows borrowers to repay debt when the contract is unpaused. This can cause debt positions still accrue debt and unable to be repaid.
Vulnerability Details
Both the functions LendingPool::repay()
and LendingPool::repayOnBehalf()
does not allow borrowers to repay debt in pause period.
function repay(uint256 amount) external nonReentrant whenNotPaused onlyValidAmount(amount) {
_repay(amount, msg.sender);
}
function repayOnBehalf(uint256 amount, address onBehalfOf) external nonReentrant whenNotPaused onlyValidAmount(amount) {
if (!canPaybackDebt) revert PaybackDebtDisabled();
if (onBehalfOf == address(0)) revert AddressCannotBeZero();
_repay(amount, onBehalfOf);
}
PoC
describe("Liquidation", function () {
...
it('unable to repay debt in pause period', async function() {
await raacHousePrices.setHousePrice(1, ethers.parseEther("90"));
await lendingPool.connect(user2).initiateLiquidation(user1.address)
await lendingPool.connect(owner).pause();
let totalDebt = await debtToken.balanceOf(user1.address);
await crvusd.mint(user1.address, totalDebt);
await crvusd.connect(user1).approve(lendingPool.target, totalDebt);
await lendingPool.connect(user1).repay(totalDebt);
})
Run the test and console shows:
LendingPool
Liquidation
1) unable to repay debt in pause period
0 passing (2s)
1 failing
1) LendingPool
Liquidation
unable to repay debt in pause period:
Error: VM Exception while processing transaction: reverted with custom error 'EnforcedPause()'
at LendingPool._requireNotPaused (@openzeppelin/contracts/utils/Pausable.sol:83)
at LendingPool.whenNotPaused (@openzeppelin/contracts/utils/Pausable.sol:55)
at LendingPool.repay (contracts/core/pools/LendingPool/LendingPool.sol:401)
Impact
Tools Used
Manual
Recommendations
Remove whenNotPaused
for repay functions