Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
Critical settlement status validation is missing in multiple loan operations in the Settlement contract, allowing users to perform operations on unsettled loans. This vulnerability enables attackers to steal funds, manipulate loan states, and bypass the intended settlement process flow, potentially resulting in significant direct financial losses to both lenders and borrowers.
Vulnerability Details
In the Settlement contract's architecture, loans must first be settled through the settle() function before any loan operations can be performed. This function executes the core fund transfers and marks the loan as settled by setting loans[loanId].settled = true. However, several critical loan operations fail to verify this settlement prerequisite:
// Example of missing validation in liquidate() function - lines 335-356functionliquidate(stringmemory_loanId,uint256liquidationAmt)externalnonReentrant{bytes32 loanId = _loanId.toBytes32(); LoanInfo memory loanInfo = loans[loanId];// Missing validation: if (!loanInfo.settled) revert LoanNotSettled(loanId);(uint256 collateralToLiquidator,uint256 collateralToProtocol)= loanInfo.liquidate(loanId, _oracle, _minimumDebtValue, liquidationAmt);// Transfers happen without settlement confirmationIERC20(loanInfo.debtTokenAddr).safeTransferFrom(msg.sender, loanInfo.lender, liquidationAmt);IERC20(loanInfo.collateralTokenAddr).safeTransferFrom(loanInfo.lender,msg.sender, collateralToLiquidator);IERC20(loanInfo.collateralTokenAddr).safeTransferFrom(loanInfo.lender, _feeCollector, collateralToProtocol);// ...}
The affected functions include:
repay() (line 277)
removeCollateral() (line 296)
addCollateral() (line 307)
liquidate() (line 335)
delivery() (line 324)
This contrasts with addCollateralBeforeSettle() and settle() which correctly implement settlement status validation:
Impact Details
This vulnerability creates multiple attack vectors with direct financial impact:
Direct Fund Theft via Operations on Unsettled Loans:
Attackers can call liquidate() on unsettled loans, extracting collateral tokens from lenders who approved allowances expecting the normal settlement flow
Users can call addCollateral() on unsettled loans, causing immediate token transfers without loan establishment
Both scenarios result in immediate and irrecoverable financial loss
Protocol State Corruption:
Premature repay() calls can manipulate loan parameters on unsettled loans
removeCollateral() can be called before proper collateralization is established
These operations break the protocol's accounting system and create inconsistent state