In the Lender.sol
contract, the repay
function allows for loan repayments. However, upon reviewing the function, it appears that there is no validation mechanism in place to ensure that the repayment is being made with the correct token (i.e., the loan token). This could potentially allow a malicious actor to repay a loan with a less valuable or even worthless token.
The repay
function, as currently implemented, lacks a verification step to ensure that the token being used for repayment matches the original loan token. This opens the possibility for a borrower to repay using a different, possibly worthless, token.
This vulnerability has a high impact. It could allow a malicious borrower to effectively repay a loan without actually returning the same value that they borrowed, leading to a loss for the lender. In a worst-case scenario, a borrower could exploit this vulnerability to drain a lender's funds.
Manual Code review
A token verification step should be added to the repay
function to ensure that repayments are made with the correct token. This can be done by checking the token being transferred against the loan token recorded when the loan was issued. Below is a sample code snippet to illustrate the recommended changes:
In this example, the repay
function retrieves the loan details, checks the repayment amount, and then verifies the token being used for repayment. If the token does not match the original loan token, or if the transfer fails for any reason, the transaction is reverted. This ensures that the borrower repays the loan with the correct token and 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.