This repository has been archived by the owner on May 26, 2023. It is now read-only.
IllIllI - Dust amounts can cause payments to fail, leading to default #218
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
IllIllI
medium
Dust amounts can cause payments to fail, leading to default
Summary
Dust amounts can cause payments to fail, leading to default
Vulnerability Detail
In order for a loan to close, the exact right number of wei of the debt token must be sent to match the remaining loan amount. If more is sent, the balance underflows, reverting the transaction.
Impact
An attacker can send dust amounts right before a loan is due, front-running any payments also destined for the final block before default. If the attacker's transaction goes in first, the borrower will be unable to pay back the loan before default, and will lose thier remaining collateral. This may be the whole loan amount.
Code Snippet
If the repayment amount isn't exactly the remaining loan amount, and instead is more (due to the dust payment), the subtraction marked below will underflow, reverting the payment:
https://github.com/sherlock-audit/2023-01-cooler/blob/main/src/Cooler.sol#L108-L124
Tool used
Manual Review
Recommendation
Only collect and subtract the minimum of the current loan balance, and the amount specified in the
repaid
variableThe text was updated successfully, but these errors were encountered: