defaulting doesn't change the state of the loan
When a loan defaults, the lender can seize the collateral, but the loan's state remains ACCEPTED, so the borrower can keep making payments. An attacker (the lender) could front-run a late payment with a collateral seizure to get both the payment and the collateral.
Dug Follow with MiloTruck, RaymondFam and 7 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-03-teller-judging/issues/317
Found by
Dug, MiloTruck, RaymondFam, cccz, cducrest-brainbot, deadrxsezzz, immeas, jpserrat, mrpathfindr, sinarette
Summary
The lender can claim the borrowers collateral in case they have defaulted on their payments. This however does not change the state of the loan so the borrower can continue making payments to the lender even though the loan is defaulted.
Vulnerability Detail
If a loan defaults the lender (or anyone) can seize the collateral and send it to the lender: https://github.com/sherlock-audit/2023-03-teller/blob/main/teller-protocol-v2/packages/contracts/contracts/CollateralManager.sol#L254-L257
File: CollateralManager.sol
254: } else if (tellerV2.isLoanDefaulted(_bidId)) {
255: _withdraw(_bidId, tellerV2.getLoanLender(_bidId)); // sends collateral to lender
256: emit CollateralClaimed(_bidId);
257: } else {
Since this is in CollateralManager nothing is updating the state kept in TellerV2 which will still be ACCEPTED. The lender could still make payments (in vain).
Impact
The borrower can continue paying unknowing that the loan is defaulted. The lender could, given a defaulted loan, see that the lender is trying to save their loan and front run the late payment with a seize of collateral. Then get both the late payment and the collateral. This is quite an unlikely scenario though.
The loan will also be left active since even if the borrower pays the withdraw of collateral will fail since the collateral is no longer there.
Code Snippet
Tool used
Manual Review
Recommendation
Remove the possibility for the lender to default the loan in CollateralManager. Move defaulting to TellerV2 so it can properly close the loan.
Discussion
ethereumdegen
PR (draft): https://github.com/teller-protocol/teller-protocol-v2/pull/103
(also see issue 311)
IAm0x52
Confirming this fix for 311/317. Looks good. When a lender claims collateral from an overdue loan, the status of the loan is changed to "CLOSED" preventing any further repayment from the borrower.
jacksanford1
Changed label to Will Fix since Teller ended up making a fix (and 0x52 reviewed it).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the collateral seizure logic lives in a separate contract (CollateralManager) that does not update the loan state in the main contract (TellerV2), leaving the loan marked as ACCEPTED.
Impact
The borrower can continue paying unknowingly on a defaulted loan, and a lender could front-run a late payment with a collateral seizure to get both the payment and the collateral, though this is unlikely; the loan also stays active.
What the attacker needed
A defaulted loan; lender acts to seize collateral
The fix
The fix was to move defaulting to TellerV2 so it can properly close the loan, and a later comment confirms that claiming collateral now changes the loan status to CLOSED.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending system, if a borrower misses payments, the lender can take the collateral. But the system didn't mark the loan as finished, so the borrower could keep sending money that the system still accepted. This could let a dishonest lender take both the collateral and a late payment.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.