mintBorrowTicketTo can be a contract with no onERC721Received method, which may cause the BorrowTicket NFT to be frozen and put users’ funds at risk
The mint function for the BorrowTicket NFT uses _mint instead of _safeMint, so if the recipient is a contract that cannot handle ERC721 tokens, the NFT may become stuck and the user's funds could be lost. An attacker could exploit this by setting a contract address that cannot receive NFTs as the mintBorrowTicketTo parameter, causing the ticket to be frozen.
Submitted by WatchPug
NFTLoanFacilitator.sol#L102-L102
IERC721Mintable(borrowTicketContract).mint(mintBorrowTicketTo, id);
function mint(address to, uint256 tokenId) external override loanFacilitatorOnly {
_mint(to, tokenId);
}
If mintBorrowTicketTo is a contract that does not implement the onERC721Received method, in the current implementation of createLoan(), the tx will still be successfully, and the loan will be created.
This can be a problem if mintBorrowTicketTo can not handle ERC721 properly, as the BorrowTicket NFT will be used later to get back the user’s funds.
Recommended Mitigation Steps
Consider using safeMint in NFTLoanTicket.sol#mint():
function mint(address to, uint256 tokenId) external override loanFacilitatorOnly {
_safeMint(to, tokenId);
}
wilsoncusack (Backed Protocol) acknowledged, but disagreed with Medium severity and commented:
Similar to #83
Not really a duplicate because it is the mint function. Fund can be lost by losing the borrow ticket.
wilsoncusack (Backed Protocol) commented:
Agree not really duplicate. I think my response is the same, which is comparing to Uniswap v3 nft which also would mean loss of funds if lost.
From #83:
We use transferFrom and _mint instead of the safe versions to save gas. We think it is a reasonable expectation that users calling this should know what they are doing, we feel this is OK especially because other major protocols like Uniswap do this NonfungiblePositionManager.sol#L156.
Given the safe variant is used in L242 and L262, looks like ERC721 safety was a concern at the time the code is written. Therefore I believe Med Risk is a fair assessment.
wilsoncusack (Backed Protocol) commented:
Fair. This was an intentional change to save gas but I should have been consistent.
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 mint function uses _mint instead of _safeMint, so it does not verify that the recipient contract can handle ERC721 tokens.
Impact
The BorrowTicket NFT could be frozen, putting the user's funds at risk, though the protocol argues this is a known trade-off for gas savings.
What the attacker needed
MintBorrowTicketTo is a contract; contract lacks onERC721Received
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.
When a contract receives an NFT, it must have a special function to accept it; otherwise, the NFT can get stuck. Here, the mint function does not check this, so if someone sends the ticket to a contract that cannot handle NFTs, the ticket is lost and the user cannot get their funds back.
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.