Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

The `DebtToken.balanceOf()` Function Doesn't Account for the Increased Balance Generated by the Usage Index Update

Summary

The DebtToken.balanceOf() function doesn't return the exact debt amount of the user, as it fails to account for the increased debt balance generated by the usage index delta between the global usage index and the user's index.

Vulnerability Details

The DebtToken.balanceOf() function doesn't account for the increased balance generated by the usage index update.

Over time, the global usage index increases. In the DebtToken logic, for every update for users, the users' indices are updated by the global usage index, and the users' debt balance is increased by the index delta between the global index and the users' index. This can be observed in the functions mint() and burn().

However, the balanceOf() function does not account for this increased balance, resulting in an incorrect return value.

function balanceOf(address account) public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledBalance = super.balanceOf(account);
return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}

Impact

balanceOf() returns an incorrect value that does not reflect the increased balance by the index delta.

Tools Used

Manual review

Recommendations

Account for the increased balance by the index delta.

function balanceOf(address account) public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledBalance = super.balanceOf(account);
- return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
+ return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt()).rayDiv(_userState[account].index);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!