Malicious lender can prevent borrower from repayment due to try/catch block revert
Source: https://github.com/sherlock-audit/2024-11-teller-finance-update-judging/issues/39
Found by
OpaBatyo, hash
Summary
Insufficient validation for try/catch address will disallow borrower's from repaying their loans
Root Cause
A malicious lender can bypass the try/catch block covering the repayLoanCallback external call by selfdestructing loanRepaymentListener
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
)
The try/catch block will revert if the call is made to a non-contract address. To avoid this a check for codesize > 0 is kept inside the setRepaymentListenerForBid function. But this can be bypassed by the lender selfdestructing the _listener in the same transaction which will delete the contract
function setRepaymentListenerForBid(uint256 _bidId, address _listener) external {
uint256 codeSize;
assembly {
codeSize := extcodesize(_listener)
}
require(codeSize > 0, "Not a contract");
address sender = _msgSenderForMarket(bids[_bidId].marketplaceId);
require(
sender == getLoanLender(_bidId),
"Not lender"
);
repaymentListenerForBid[_bidId] = _listener;
}
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
- Lender creates a contract which can
selfdestructitself - Lender sets this address as the repaymentListener
- In the same tx, the lender destroys the contract
- Now the borrower cannot repay because the try/catch block will always revert
Impact
Borrowers will not be able to repay the loan allowing the lender to steal the collateral after the loan will default
PoC
No response
Mitigation
Use .call instead of the try/catch
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/79
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity business logic bug in Teller Lender Groups Update Audit. Sherlock made it public on 15 December 2024. Found in the 472 audit contest (finding H-2), also found by 1 other warden.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.