A borrower can not repay to a USDC blacklisted lender
A borrower repays a loan by transferring USDC directly to the lender, so if the lender is blacklisted by USDC, the transfer fails and the borrower cannot repay. The borrower then loses their collateral when the lender calls the loan and seizes it.
Source: https://github.com/sherlock-audit/2024-09-predict-fun-judging/issues/85
The protocol has acknowledged this issue.
Found by
000000, 0rpse, 0xnbvc, GGONE, PUSH0, Pheonix, Sickurity, SyncCode2017, bughuntoor, iamnmt, kennedy1030, t.aksoy, valuevalk
Summary
A borrower transfers LOAN_TOKEN directly to a lender when repaying their loan will cause the loan can not to be repaid when the lender is blacklisted by the LOAN_TOKEN.
Root Cause
A borrower repays their loan by transferring LOAN_TOKEN directly to a lender
function repay(uint256 loanId) external nonReentrant {
Loan storage loan = loans[loanId];
_assertAuthorizedCaller(loan.borrower);
LoanStatus status = loan.status;
if (status != LoanStatus.Active) {
if (status != LoanStatus.Called) {
revert InvalidLoanStatus();
}
}
uint256 debt = _calculateDebt(loan.loanAmount, loan.interestRatePerSecond, _calculateLoanTimeElapsed(loan));
loan.status = LoanStatus.Repaid;
>> LOAN_TOKEN.safeTransferFrom(msg.sender, loan.lender, debt);
CTF.safeTransferFrom(address(this), msg.sender, loan.positionId, loan.collateralAmount, "");
emit LoanRepaid(loanId, debt);
}
When LOAN_TOKEN is USDC, and the lender is blacklisted, the borrower can not transfer USDC to repay the lender.
Internal pre-conditions
LOAN_TOKENisUSDC- The borrower has borrowed from the lender before the lender is blacklisted by
USDC.
External pre-conditions
The lender is blacklisted by USDC
Attack Path
- The borrower borrows from the lender
- The lender is blacklisted by
USDC - The borrower can not repay the lender
Impact
- The borrower can not repay their loan
- The borrower can not get their collateral tokens (ERC1155) back
- When the loan is matured, the lender can call the loan, and then seize all the collateral tokens (Note that, since the new lender also has to transfer
USDCto the old lender, the auction functionality will not work, and the lender will guarantee to seize all the collateral tokens)
PoC
No response
Mitigation
Implement a pushing method for repaying a loan:
- The borrower repays a loan by transferring the
LOAN_TOKENto thePredictDotLoancontract, and the loan amounts are credited to the lender. - The lender claims the loan amounts back from the
PredictDotLoancontract.
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
The repayment function transfers the loan token directly to the lender, so a blacklisted lender address causes the transfer to revert.
Impact
The borrower cannot repay the loan or recover their collateral, and when the loan matures the lender can call it and seize all the collateral tokens.
What the attacker needed
LOAN_TOKEN is USDC; Lender is blacklisted by USDC; Borrower has an active loan from that lender
The fix
The protocol should change repayment so the borrower sends the loan token to the contract and the lender later claims the funds, avoiding a direct transfer to a blacklisted address.
How it was found
- The borrower borrows from the lender
- The lender is blacklisted by USDC
- The borrower can not repay the lender
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.
This is a smart contract bug where a borrower tries to pay back a loan by sending a digital dollar token (USDC) straight to the lender. But if the lender's address is blocked by the token issuer, the payment is rejected, so the borrower can never clear the debt. The borrower then loses the collateral they put up for the loan.
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.