The vulnerability exists in the debt repayment logic (Lines 312-335) of the LendingPool contract, which uses the balanceOf method of the DebtToken to calculate repayable amounts. If the DebtToken is transferable, attackers can artificially inflate their debt balances to drain protocol reserves or trigger underflows in user debt tracking.
The _repay function calculates the user’s debt using IDebtToken(reserve.reserveDebtTokenAddress).balanceOf(onBehalfOf), which returns the current ERC20 balance of the debt token. If the DebtToken is transferable (not explicitly restricted), attackers can:
Transfer debt tokens to a target user’s address.
Exploit the inflated debt balance to repay more than their actual debt.
Cause underflows in the scaledDebtBalance variable, corrupting protocol state.
Protocol Insolvency: Attackers can repay inflated debts, withdrawing collateral without owing real funds.
Debt Tracking Corruption: Negative scaledDebtBalance values disrupt interest calculations.
Reserve Drain: Malicious users can mint unlimited debt tokens to steal liquidity.
Manual Code Review: Identified reliance on transferable DebtToken balances.
Slither: Detected unsafe ERC20 balance usage in critical logic.
Foundry: Simulated debt token transfers and underflow attacks.
An attacker transfers debt tokens to a victim, tricking the protocol into accepting over-repayments that underflow scaledDebtBalance.
Attacker: Transfers debt tokens to victims to manipulate balances.
Victim: Unknowingly repays an inflated debt, corrupting their position.
Protocol: Tracks debt incorrectly, leading to reserve losses.
Restrict DebtToken Transfers:
Implement a non-transferable ERC20 variant (e.g., OpenZeppelin’s ERC20Snapshot) for the DebtToken.
Use Internal Debt Tracking:
Replace balanceOf with the stored scaledDebtBalance to compute repayable amounts:
Add Validation in DebtToken:
Override the transfer function to revert all transfers:
The transferability of debt tokens breaks core protocol invariants, enabling attackers to manipulate debt balances and drain reserves. Immediate mitigation requires disabling transfers and revising debt calculation logic.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.