#47112 [SC-Critical] addCollateral causes double economic loss through premature asset transfer and inflated settlement requirements

Submitted on Jun 9th 2025 at 02:46:06 UTC by @Catchme for IOP | Term Structure Institutional

  • Report ID: #47112

  • Report Type: Smart Contract

  • Report severity: Critical

  • Target: https://github.com/term-structure/tsi-contract/blob/main/src/Settlement.sol

  • Impacts:

    • Protocol insolvency

    • 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

  1. 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);
    // ...
}
  1. State Inflation: The LoanLib.addCollateral method increases the recorded collateral amount:

  1. 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:

  1. 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

  2. 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

Proof of Concept

Proof of Concept

Was this helpful?