Skip to content
Business logic Audit finding Intermediate

The `totalPrincipalTokensRepaid` and `totalInterestCollected` may not be updated even when funds are already transferred

The repayLoanCallback function in LenderCommitmentGroup_Smart can revert when the contract is paused, but the caller uses a try/catch that swallows the revert, so the repayment transaction succeeds and funds are transferred without updating totalPrincipalTokensRepaid and totalInterestCollected. This leads to an incorrect exchange rate calculation, potentially causing a loss of funds for shareholders.

KupiaSec Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-teller-finance-update-judging/issues/54

Found by

KupiaSec

Summary

The LenderCommitmentGroup_Smart.repayLoanCallback() function will be paused, causing the transaction to continue despite the revert. As a result, while the funds are transferred, the amounts will not be added to totalPrincipalTokensRepaid and totalInterestCollected. This discrepancy will lead to an incorrect calculation of the exchange rate, potentially resulting in a loss of funds for shareholders.

Root Cause

The LenderCommitmentGroup_Smart.repayLoanCallback() function will revert due to being paused. https://github.com/sherlock-audit/2024-11-teller-finance-update/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/LenderCommitmentForwarder/extensions/LenderCommitmentGroup/LenderCommitmentGroup_Smart.sol#L928-L945

Solidity
    function repayLoanCallback(
        uint256 _bidId,
        address repayer,
        uint256 principalAmount,
        uint256 interestAmount
@>  ) external onlyTellerV2 whenForwarderNotPaused whenNotPaused bidIsActiveForGroup(_bidId) { 
        totalPrincipalTokensRepaid += principalAmount;
        totalInterestCollected += interestAmount;

         emit LoanRepaid(
            _bidId,
            repayer,
            principalAmount,
            interestAmount,
            totalPrincipalTokensRepaid,
            totalInterestCollected
        );
    }

However, the whole transaction will not be reverted because of the try/catch statement. https://github.com/sherlock-audit/2024-11-teller-finance-update/blob/main/teller-protocol-v2-audit-2024/packages/contracts/contracts/TellerV2.sol#L938-950

Solidity
        if (loanRepaymentListener != address(0)) {
            require(gasleft() >= 80000, "NR gas");  //fixes the 63/64 remaining issue
@>          try
                ILoanRepaymentListener(loanRepaymentListener).repayLoanCallback{
                    gas: 80000
                }( //limit gas costs to prevent lender preventing repayments
                    _bidId,
                    _msgSenderForMarket(bid.marketplaceId),
                    _payment.principal,
                    _payment.interest
                )
@>          {} catch {}
        }

Borrowers can repay their loans even during a pause. This means that while the funds are transferred, the amounts will not be added to totalPrincipalTokensRepaid and totalInterestCollected. Consequently, the exchange rate will be calculated incorrectly, which could result in a loss of funds for shareholders.

Internal pre-conditions

none

External pre-conditions

none

Attack Path

none

Impact

Loss of fund to shareholders.

PoC

none

Mitigation

The LenderCommitmentGroup_Smart.repayLoanCallback() function should not revert when paused.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/teller-protocol/teller-protocol-v2-audit-2024/pull/83

The original report as published on Sherlock, by KupiaSec. 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

Likely the use of a try/catch around the repayLoanCallback call that swallows reverts, combined with the callback reverting when the contract is paused, allows repayments to succeed without updating the accounting totals.

Impact

Shareholders could lose funds because the exchange rate is calculated from incorrect totals.

What the attacker needed

Contract is paused; borrower repays loan

The fix

The repayLoanCallback function should not revert when the contract is paused; the protocol team fixed this issue in a pull request.

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.

A smart contract tracks how much borrowers have repaid using two totals. When a borrower repays, a callback function is supposed to update those totals. But if the contract is paused, that callback fails, and the main repayment still goes through because the error is ignored. So the totals become wrong, and the exchange rate used for shareholders is calculated incorrectly, which can cost them money.

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 KupiaSec

View all

28 more disclosed reports, best first.

More from Teller Lender Groups Update Audit

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.