When an attacker lends to a loan, the attacker can trigger DoS that any lenders can not buyout it
An attacker who is a lender can use an ERC777 token as the loan asset to make buyout transactions revert, preventing other lenders from buying out the loan. The attacker can also block repayment, potentially leading to default and seizure of the borrower's collateral.
Submitted by rayn, also found by hake
NFTLoanFacilitator.sol#L205-L208 NFTLoanFacilitator.sol#L215-L218
If an attacker (lender) lends to a loan, the attacker can always revert transactions when any lenders try to buyout, making anyone can not buyout the loan of the attacker.
Proof of Concept
- A victim calls
lend(), trying to buyout the loan of the attacker. - In
lend(), it always callERC20(loanAssetContractAddress).safeTransferto sendaccumulatedInterest + previousLoanAmounttocurrentLoanOwner(attacker). - If the
transferofloanAssetContractAddressis ERC777, it will call_callTokensReceivedthat the attacker can manipulate and always revert it. - Because
NFTLoanFacilitatorusessafeTransferandsafeTransferFromto check return value, the transaction of the victim will also be reverted. It makes anyone can not buyout the loan of the attacker.
In _callTokensReceived, the attacker just wants to revert the buyout transaction, but keep repayAndCloseLoan successful. The attacker can call loanInfoStruct(uint256 loanId) in _callTokensReceived to check if the value of loanInfo is changed or not to decide to revert it.
Tools Used
vim
Recommended Mitigation Steps
Don’t transfer ERC20(loanAssetContractAddress) to currentLoanOwner in lend(), use a global mapping to record redemption of lenders and add an external function redeem for lenders to transfer ERC20(loanAssetContractAddress).
wilsoncusack (Backed Protocol) acknowledged, but disagreed with High severity and commented:
I think this is just part of perils of working with certain assets and I am not sure we will mitigate.
wilsoncusack (Backed Protocol) confirmed and commented:
Sorry, I lost track of this one/labeled incorrectly. This is indeed an issue we intend to address: we will block erc777 tokens.
The worse implication here is that a lender could prevent a borrower from repaying and could seize the NFT.
Still not sure if this should be High or Medium. But there are legit ERC777 tokens that a borrower might selecting unknowingly, so probably is High?
gzeon (judge) decreased severity to Medium and commented:
I suggest this as Med Risk as no fund is loss by preventing buyout.
wilsoncusack (Backed Protocol) commented:
But as I said above the bigger issue is they could block repayment, guaranteeing default and seizure of collateral?
I think you are correct as there is a similar call in L241. However, both wardens failed to describe such attack path and I am inclined to keep this as Med Risk.
wilsoncusack (Backed Protocol) resolved
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 contract uses safeTransfer to send ERC20 tokens, which for ERC777 tokens triggers a callback to the recipient, allowing the recipient to revert the transaction.
Impact
The attacker can prevent buyouts and also block repayment, which could lead to default and seizure of the borrower's collateral.
What the attacker needed
Attacker is a lender; loan asset is an ERC777 token; attacker controls the recipient contract
The fix
The protocol should block ERC777 tokens as loan assets, as the team intends to do.
How it was found
- A victim calls lend() to buy out the attacker's loan.
- lend() calls safeTransfer to send accumulatedInterest + previousLoanAmount to the current loan owner (attacker).
- If the loan asset is ERC777, the transfer triggers _callTokensReceived on the attacker's contract.
- The attacker's contract reverts in _callTokensReceived, causing the victim's transaction to revert.
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 a lending system, a lender provides a loan and later someone else can buy out that loan by paying the lender. If the token used for the loan has a feature that calls back to the lender on every transfer, the lender can make that callback fail, causing the buyout to fail. This means the lender can stop anyone from taking over the loan, and even stop the borrower from repaying.
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.