The debt() function incorrectly returns its parameters, using "amount" and "amountScaled" interchangeably, leading to confusion and potential errors.
In this line from the _repay()
Looking up to the burn() from the DebtToken contract
https://github.com/Cyfrin/2025-02-raac/blob/main/contracts/core/tokens/DebtToken.sol#L181-#L214
The issue lies in the return values of the burn() function, which are incorrectly ordered. It returns (amount, totalSupply(), amountScaled, balanceIncrease), but the calling function expects (amountScaled, newTotalSupply, amountBurned, balanceIncrease). This mismatch means that amountScaled is assigned the underlying amount, while amountBurned is assigned the scaled amount (amountScaled).
This discrepancy propagates to the _repay function and affects subsequent operations, such as the asset transfer here:
Due to the incorrect assignment, this transfers the underlying amount instead of the intended scaled amount, potentially leading to incorrect token accounting or transfer amounts.
Also this line, its incorrectly reduce the user scaled debt balance by amount scaled instead of underlying amount
Manual Review
Fix the orders correctly
This is confusing naming but functionally correct. The variable names are misleading, but that's not a vulnerability.
This is confusing naming but functionally correct. The variable names are misleading, but that's not a vulnerability.
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.