In the LendingPool::_repay function, when the repayment amount exceeds the user's debt, the excess is not refunded to the caller. The repayment is capped at the user's scaled debt, but there is no mechanism to return any excess funds to the caller, potentially leading to asset loss.
The function repays a user's debt, but if the repayment amount exceeds the user's scaled debt, it is capped. However, the code does not handle the excess amount, meaning any overpayment is not returned to the caller.
Callers who repay more than the user's debt may lose the excess funds, as they are not refunded.
Manual review
Implement a mechanism to refund any excess repayment to the caller. After the repayment amount is capped, the difference between the original repayment and the capped value should be returned to the caller to prevent loss of funds. Additionally, actualRepayAmount should be burned instead of amount.
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.