20,000 USDC
View results
Submission Details
Severity: medium
Valid

The refinance function in Lender.sol contains a DoS (Denial of Service) vulnerability when using USDT as lend tokens.

Summary

Lender.sol - DoS Vulnerability in Refinance with USDT Small Debt Difference

Vulnerability Details

The refinance function calculates a fee based on the difference between the debt and debtToPay values. However, if this difference is small and falls below a certain threshold, the calculated fee may become zero, leading to a zero transfer of USDT tokens, which is not supported by the USDT token contract. As a result, the transaction reverts, causing a DoS vulnerability during the refinancing process.

function refinance(Refinance[] calldata refinances) public {
...
} else if (debtToPay < debt) {
// we have excess loan tokens so we give some back to the borrower
// first we take our borrower fee
// @audit fee could potentially be 0 if debt diff is too small (less than 200)
uint256 fee = (borrowerFee * (debt - debtToPay)) / 10000;
IERC20(loan.loanToken).transfer(feeReceiver, fee);
// transfer the loan tokens from the contract to the borrower
IERC20(loan.loanToken).transfer(msg.sender, debt - debtToPay - fee);
}
...
}

Impact

When this occurs, the borrower is subject to a DoS attack, as the refinancing process will fail for the entire loop. This can lead to significant gas wastage, especially if the loop is large.

Tools Used

Manual Review

Recommendations

To mitigate this issue, it is recommended to skip executing the transfer if the fee is zero, preventing the transaction from reverting and avoiding the DoS vulnerability during the refinancing process.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!