Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
The addCollateral function in the Settlement contract suffers from a critical vulnerability that causes both premature asset transfer and settlement amount inflation, resulting in double economic loss. If exploited in production, this would lead to significant financial losses for users adding collateral to unsettled loans, as tokens would be transferred immediately to lenders while simultaneously increasing the settlement requirements, effectively forcing the same value to be paid twice.
Vulnerability Details
Immediate Asset Transfer: The addCollateral method immediately transfers collateral tokens to the lender, even for unsettled loans:
function addCollateral(string memory _loanId, uint256 addCollateralAmt) external nonReentrant {
// ...
loanInfo.addCollateral(addCollateralAmt); // Increases recorded collateral amount
loans[loanId] = loanInfo;
// Immediate transfer to lender regardless of settlement status
IERC20(loanInfo.collateralTokenAddr).safeTransferFrom(msg.sender, loanInfo.lender, addCollateralAmt);
// ...
}
State Inflation: The LoanLib.addCollateral method increases the recorded collateral amount:
Settlement Double-Transfer: During settlement, the borrower must transfer the entire recorded collateral amount, which now includes previously transferred tokens:
Logical Flaw: The system assumes collateral should only be transferred during settlement as an atomic operation, but addCollateral violates this principle by transferring assets immediately while simultaneously inflating future settlement requirements.
Impact Details
This vulnerability creates severe economic consequences for multiple parties:
Direct Financial Loss to Callers:
Any address calling addCollateral() loses their tokens immediately with no compensation
These users transfer tokens to lenders without establishing proper custodial relationships
In production, this could lead to significant financial losses proportional to added collateral amounts
Inflated Settlement Costs for Borrowers:
Borrowers must transfer additional collateral during settlement equal to all previous addCollateral amounts
Original loan terms become economically disadvantageous beyond agreed parameters
Settlement becomes unpredictably more expensive than initially calculated