Fast Steel Cormorant
Medium
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.
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:
Issues Identified:
-
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 by10^16
. Consequently, anyparams.amount
less than10^16
effectively becomes0
after division. -
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).
- 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.
-
Asset Selection: An attacker selects a collateral asset with high decimal precision (e.g., 18 decimals) supported under Isolation Mode.
-
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 of0
. - Example: Borrowing amounts like
9.9e15
, which, when divided by10^16
, yield0
.
- The attacker initiates numerous borrow transactions, each with an amount just below the threshold where
-
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.
- Each transaction increases the actual debt owed by the attacker but fails to reflect accurately in
-
Exploitation Outcome:
- The attacker maintains a highly leveraged position beyond risk limits, exposing the protocol to substantial bad debt and potential liquidity issues.
Adjust Debt Calculation Precision:
- Rounding Up: Modify the division operation to round up any fractional results, ensuring that even minimal borrows increment
isolationModeTotalDebt
.