When a new loan is created, the status of the loan is set to loans[id].status = LoanStatus.Active. However, when a borrower repays a loan, the status is not reset when a lender wants to initiate a auction calls the function call
The function only sets the status to "repaid" but doesn't reset the active status of the loan. As a result, a malicious user can call the auction on an empty loan and exploit another lender who will buy the empty loan,
even in the auction function theres is no check if the loan is repaid the function only checks if the loan is active which will be true since the status is never reset
nikhilx0111
High
a malicious lender can sell already repaid loan
Summary
When a new loan is created, the status of the loan is set to loans[id].status = LoanStatus.Active. However, when a borrower repays a loan, the status is not reset when a lender wants to initiate a auction calls the function call
the code checks if the status is active and if the loan has matured but theres no check if the loan is repaid now when we see the repay function
The function only sets the status to "repaid" but doesn't reset the active status of the loan. As a result, a malicious user can call the auction on an empty loan and exploit another lender who will buy the empty loan, even in the auction function theres is no check if the loan is repaid the function only checks if the loan is active which will be true since the status is never reset
Root Cause
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L454-L473
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L534-L550
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L561-L568
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
loss of funds for innocent lenders who will buy the empty loan
PoC
No response
Mitigation
reset the status of the loan when the loan is repaid