Submitted by SpicyMeatball, also found by 0x73696d616f
User may revoke the underlying asset approval from the yield contract and prevent the botAdmin from repaying and closing his position. As a result, the debt will not be repaid, leaving the protocol at a loss.
Lets take a closer look at the _repay function:
If the yield collected by the position is not enough to cover the entire debt and fines, the protocol will attempt to collect extraAmount from the position owner, but he may revoke ERC20 approval and cancel the safeTransferFrom function call. As a result, nftDebt will not be repaid and will continue to collect interest, increasing the protocols losses.
It is recommended to separate the logic of debt repayment and NFT unlocking. The _repay function will reduce the debt of the position using the collected yield and unlock the NFT only if extraAmount is zero. In case extraAmount is greater than zero, leave the token locked and allow the NFT owner to unlock it only after he has repaid the remaining debt.
thorseldon (BendDAO) confirmed and commented:
