DebtToken's mint function fails to properly scale balances when the usage index is very high, leading to incorrect debt accounting. This could cause users to have more debt than intended, potentially destabilizing the lending protocol's economics.
The issue occurs in the mint function when calculating scaled amounts using ray division. When a user borrows tokens, the contract attempts to scale their debt using the current usage index. However, if the index becomes significantly high, the ray division calculation produces incorrect results, leading to improper debt tracking.
We expects scaled balances to match the ray division calculation of amount/index. However, with a high index value, the actual scaled balance differs from the expected value.
Looking at DebtToken.sol:
At its core, the DebtToken contract tracks user borrowing positions against real estate NFT collateral.
Think of the DebtToken like a mortgage ledger, it needs to perfectly track every dollar borrowed. The issue emerges in the mint function's scaling calculations, particularly when dealing with large house valuations and borrowing amounts.
The key interaction happens between the LendingPool and DebtToken contracts. When a user borrows against their RAAC NFT collateral, the protocol:
Values the property using RAACHousePrices oracle
Calculates maximum borrowing power
Mints debt tokens to track the loan
We found that the debt scaling calculation can produce incorrect results with certain combinations of:
Large property valuations (tracked in RAACHousePrices)
High utilization rates (affecting the interest rate index)
Significant borrowing amounts
When a property owner takes a loan through the LendingPool, their debt gets tracked by the DebtToken contract. The contract uses ray math (27 decimal precision) to scale debt amounts based on the current interest rate index. However, the scaling calculation breaks down when handling luxury properties worth millions of dollars.
The vulnerability centers around the ray division operation where amount.rayDiv(index) can produce incorrect results with large real estate values. This scaling operation affects all subsequent calculations in the function.
Here's what happens: A user deposits a high-value property NFT (tracked in RAACHousePrices) and requests a loan. The LendingPool calculates their borrowing power and calls DebtToken.mint(). At this point, the ray division between the large loan amount and current index produces incorrect results, leading to mismatched debt accounting.
This precision loss has real consequences. For a $5 million property with 80% LTV ($4M borrowing power), the debt token balance could be off by hundreds of thousands of dollars. This directly impacts:
The borrower's actual debt obligation
The protocol's collateralization calculations
The accuracy of total debt tracking
In real estate lending, even small accounting errors compound significantly over time. A borrower could end up with a debt position that's materially different from their actual borrowed amount.
For example, on a $500,000 property with 80% LTV, the debt token balance could be off by several thousand dollars due to scaling imprecision. This directly impacts:
Borrower's collateralization ratio
Protocol's risk calculations
Overall system solvency
The assumption is standard DeFi token scaling would work for real estate values. However, RAAC's unique position as a real-world asset protocol means dealing with significantly larger numbers than typical DeFi applications.
when dealing with real-world assets. We should:
Implement strict bounds on the interest rate index
Add safety checks in the scaling calculations
Consider using a more precise numerical representation for real estate values
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.