Skip to content

Latest commit

 

History

History
51 lines (30 loc) · 3.35 KB

096.md

File metadata and controls

51 lines (30 loc) · 3.35 KB

Fast Steel Cormorant

Medium

Precision Loss Vulnerability in Isolation Mode within BorrowLogic::executeBorrow

Summary

A critical flaw exists in the Isolation Mode of Aave v3.3, specifically within the executeBorrow function of the BorrowLogic contract. Isolation Mode is intended to restrict users from exceeding predefined debt ceilings when leveraging certain assets as collateral. However, due to an unintended precision loss in debt calculations, the system inaccurately tracks user debt, allowing users to surpass their designated borrowing limits.

Vulnerability details

The vulnerability stems from the method used to calculate and update the isolationModeTotalDebt. The calculation involves integer division followed by casting the result to a smaller data type (uint128), which inadvertently truncates fractional values. The problematic code segment is as follows:

https://github.com/sherlock-audit/2025-01-aave-v3-3/blob/main/aave-v3-origin/src/contracts/protocol/libraries/logic/BorrowLogic.sol#L110-L119

Issues Identified:

  1. Integer Division Truncation: Solidity's integer division discards any fractional component. For assets with high decimal precision (e.g., 18 decimals), subtracting ReserveConfiguration.DEBT_CEILING_DECIMALS (commonly 2) results in dividing by 10^16. Consequently, any params.amount less than 10^16 effectively becomes 0 after division.

  2. Inadequate Type Casting: Casting the result directly to uint128 without ensuring that the value fits within its range can lead to silent truncation or, in cases of overflow, transaction reversion (in Solidity ^0.8.0 and above).

Impact

  • Consequences:
    • Debt Ceiling Bypass: Users can perform multiple small borrow transactions that individually do not breach the debt ceiling but cumulatively exceed it due to the precision loss.
    • Underestimated Protocol Risk: The protocol's tracking mechanisms underestimate user debt, increasing exposure to bad debt, especially during collateral price volatility or liquidation failures.
    • Systemic Stability Threat: Persistent undercounting of debt undermines the integrity of risk management strategies, potentially destabilizing the entire lending ecosystem.

Attack Vector

  1. Asset Selection: An attacker selects a collateral asset with high decimal precision (e.g., 18 decimals) supported under Isolation Mode.

  2. Repeated Small Borrows:

    • The attacker initiates numerous borrow transactions, each with an amount just below the threshold where params.amount / 10^16 results in a truncated value of 0.
    • Example: Borrowing amounts like 9.9e15, which, when divided by 10^16, yield 0.
  3. Accumulated Debt:

    • Each transaction increases the actual debt owed by the attacker but fails to reflect accurately in isolationModeTotalDebt.
    • Over time, the attacker’s total debt significantly surpasses the intended ceiling without triggering protocol safeguards.
  4. Exploitation Outcome:

    • The attacker maintains a highly leveraged position beyond risk limits, exposing the protocol to substantial bad debt and potential liquidity issues.

Mitigation Recommendations

Adjust Debt Calculation Precision:

  • Rounding Up: Modify the division operation to round up any fractional results, ensuring that even minimal borrows increment isolationModeTotalDebt.