# When an attacker lends to a loan, the attacker can trigger DoS that any lenders can not buyout it

Attacker lender using ERC777 loan asset reverts token-received hook to block buyout and repayment, forcing borrower default and NFT seizure.

- Payout: Audit contest
- Severity: medium
- Program: Backed Protocol
- Credited: rayn
- Disclosed: 2022-04-21
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-04-backed-findings/issues/89
- Library page: https://bugbountylibrary.com/r/c4%3A2022-04-backed%3AM-01
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** NFTLoanFacilitator.lend() / repayAndCloseLoan() ERC20 safeTransfer to currentLoanOwner
**Root cause:** lend() and repayAndCloseLoan() push loanAssetContractAddress to currentLoanOwner via safeTransfer; if the asset is ERC777, the recipient's tokensReceived hook runs and can revert, blocking the transfer.
**Steps:**
1. Victim calls `lend()` to buyout attacker's loan.
2. lend() calls `ERC20(loanAssetContractAddress).safeTransfer(currentLoanOwner, accumulatedInterest + previousLoanAmount)`.
3. If loanAssetContractAddress is ERC777, `_callTokensReceived` executes on attacker's contract.
4. Attacker's hook reads `loanInfoStruct(loanId)`; if loanInfo unchanged (buyout path) it reverts, reverting victim's tx.
5. Same hook logic allows repayAndCloseLoan to succeed while blocking buyout, or reverts repayment to force default.
**How found:** Code reading of lend()/repayAndCloseLoan() safeTransfer calls to currentLoanOwner, noticing ERC777 tokensReceived callback gives recipient control over the transfer outcome.
**Exploitation:** Attacker becomes lender with an ERC777 loan asset; on any buyout attempt the hook reverts, so no one can buy out. Attacker can also revert repayment, guaranteeing borrower default and seizure of the NFT collateral.
**Escalation:** Extending the same hook revert to repayAndCloseLoan (L241) blocks repayment, forcing default and collateral seizure.
**Insight:** When a protocol pushes ERC20 tokens to a user-controlled address, check whether the asset could be ERC777 (or otherwise hook-bearing) so the recipient can revert and grief state transitions like buyout/repayment.
