Skip to content
Business logic Audit finding Intermediate

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.

000000 Follow with 0rpse, 0xnbvc and 10 others

Originally disclosed on Sherlock

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

https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L470

Solidity
    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

  1. LOAN_TOKEN is USDC
  2. 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

  1. The borrower borrows from the lender
  2. The lender is blacklisted by USDC
  3. The borrower can not repay the lender

Impact

  1. The borrower can not repay their loan
  2. The borrower can not get their collateral tokens (ERC1155) back
  3. 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 USDC to 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:

  1. The borrower repays a loan by transferring the LOAN_TOKEN to the PredictDotLoan contract, and the loan amounts are credited to the lender.
  2. The lender claims the loan amounts back from the PredictDotLoan contract.

The original report as published on Sherlock, by 000000. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. The borrower borrows from the lender
  2. The lender is blacklisted by USDC
  3. 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.

More by 000000

View all

32 more disclosed reports, best first.

More from predict.fun lending market

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.