If `repayLoanCallback` address doesn't implement `repayLoanCallback` try/catch won't go into the catch and will revert the tx
A lender can set a loan repayment listener contract that does not implement the repayLoanCallback function, causing the try/catch in the repayment function to revert instead of catching the error. This prevents borrowers from repaying their loans, forcing default and allowing the lender to seize collateral.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-04-teller-finance-judging/issues/178
Found by
EgisSecurity
Summary
If repayLoanCallback address doesn't implement repayLoanCallback try/catch won't go into the catch and will revert the tx
Vulnerability Detail
If a contract, which is set as loanRepaymentListener from a lender doesn't implement repayLoanCallback transaction will revert and catch block won't help.
This is serious and even crucial problem, because a malicous lender could prevent borrowers from repaying their loans, as repayLoanCallback is called inside the only function used to repay loans. This way he guarantees himself their collateral tokens.
if (loanRepaymentListener != address(0)) {
try
ILoanRepaymentListener(loanRepaymentListener).repayLoanCallback{
gas: 80000
}( //limit gas costs to prevent lender griefing repayments
_bidId,
_msgSenderForMarket(bid.marketplaceId),
_payment.principal,
_payment.interest
)
{} catch {}
}
Impact
Lenders can stop borrowers from repaying their loans, forcing their loans to default.
Code Snippet
Tool used
Manual Review
Recommendation
Maybe use a wrapper contract, which is trusted to you and is internally calling the repayLoanCallback on the untrusted target.
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/31
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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 try/catch only catches reverts from the called function, not from calling a non-existent function on a contract that lacks it, so the external call reverts before the catch block can handle it.
Impact
A malicious lender could prevent borrowers from repaying, forcing loans to default and allowing the lender to take collateral.
What the attacker needed
Lender sets a malicious listener contract; borrower attempts to repay
The fix
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.
In Ethereum smart contracts, a lender can attach a listener contract that gets notified when a loan is repaid. If that listener contract is missing the required notification function, the repayment transaction fails entirely, even though the code tries to catch errors. This lets a malicious lender block repayments and take the borrower's collateral.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.