The burn function incorrectly uses the raw amount instead of the scaled amountScaled when burning tokens and transferring underlying assets. This leads to an inconsistency in accounting, where the actual burned amount does not reflect the proper scaled value based on the index, potentially leading to incorrect balances and value discrepancies.
The function is designed to burn an amount of tokens and transfer the underlying asset accordingly. However, it incorrectly:
Burns the raw amount instead of amountScaled: The function calculates amountScaled using rayMul(index), but does not use it in the _burn function. As a result, the burned token amount does not reflect the proper scaling factor, leading to incorrect accounting.
Transfers the raw amount instead of amountScaled: The safeTransfer function sends amount tokens instead of amountScaled, which means the receiver gets an unscaled amount, causing an imbalance between the burned tokens and the redeemed underlying assets.
Double Index Update: _userState[from].index = index.toUint128(); is set twice, which is unnecessary and redundant.
Accounting Inconsistencies: The burned amount does not properly reflect the intended value, leading to incorrect total supply calculations.
Potential Exploitation: If the contract relies on correct burning mechanics for financial accuracy, users might be able to withdraw more assets than they should.
Balance Discrepancies: The underlying asset transfers do not align with the scaled burned amount, leading to incorrect distributions.
Manual review.
To fix this issue:
Use amountScaled instead of amount in _burn:
Transfer amountScaled instead of amount:
Remove redundant index updates:
This vulnerability could lead to financial inconsistencies and incorrect balance accounting within the protocol. Implementing the proposed fixes will ensure proper scaling and accurate token burns and transfers.
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.