Open code423n4 opened 2 years ago
I think this is just part of perils of working with certain assets and I am not sure we will mitigate
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?
I suggest this as Med Risk as no fund is loss by preventing buyout.
I suggest this as Med Risk as no fund is loss by preventing buyout.
But as I said above the bigger issue is they could block repayment, guaranteeing default and seizure of collateral?
I suggest this as Med Risk as no fund is loss by preventing buyout.
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 warden failed to describe such attack path and I am inclined to keep this as Med Risk.
resolved with https://github.com/with-backed/backed-protocol/pull/69
Lines of code
https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L205-L208 https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L215-L218
Vulnerability details
Impact
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
lend()
, trying to buyout the loan of the attacker.lend()
, it always callERC20(loanAssetContractAddress).safeTransfer
to sendaccumulatedInterest + previousLoanAmount
tocurrentLoanOwner
(attacker).transfer
ofloanAssetContractAddress
is ERC777, it will call_callTokensReceived
that the attacker can manipulate and always revert it.NFTLoanFacilitator
usessafeTransfer
andsafeTransferFrom
to 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 keeprepayAndCloseLoan
successful. The attacker can callloanInfoStruct(uint256 loanId)
in_callTokensReceived
to check if the value ofloanInfo
is changed or not to decide to revert it.Tools Used
vim
Recommended Mitigation Steps
Don't transfer
ERC20(loanAssetContractAddress)
tocurrentLoanOwner
inlend()
, use a global mapping to record redemption of lenders and add an external functionredeem
for lenders to transferERC20(loanAssetContractAddress)
.