Open hats-bug-reporter[bot] opened 1 year ago
out of scope. TY!
@seongyun-ko
I don't agree here as the issues impact is real. Further this issue is not found in previous audits and it also does not fall in following OOS rules,
I would request the reference of this issue is being considered here as OOS by you as i believe this issue should be considered and further mitigated.
Github username: @0xRizwan Submission hash (on-chain): 0x7bed06542227884aaecf5b2b1077a8ca0853b1bc225f6bf457f31338434d1657 Severity: medium
Description: Description\
NFTExchange.sol
contract is used for escrowing NFT trades between a multi-sig wallet and a staker.The contract basically deals with
T-NFTs
andmembershipNft
. There is no issue withmembershipNft
while transferring to recipient, howeverT-NFTs
have issue while transferring to recipient address. To be noted,T-NFTs
is an ERC721 token.The issue is in
buy()
function which allows a reserved buyer to purchase amembership NFT
with aT-NFT
.As seen above, transferFrom() method is used while trasferring the
tNft
instead of safeTransferFrom(). I however argue that this isn’t recommended because:1) The issue is if the recepient is a contract address, the NFT will be locked or frozen because of NO check
OnERC721Received
support in current implementation.2) Openzeppelin encourages to use safeTransferFrom instead of transferFrom and in ER721.sol, the comment says,
3) OpenZeppelin’s documentation discourages the use of transferFrom(), Use safeTransferFrom() whenever possible,
Openzeppelin warns of using transfer( ) by saying,
Also, As per the documentation of EIP-721:
Reference: https://eips.ethereum.org/EIPS/eip-721
However,
owner()
is hardcoded and there is no parameter to put the recipient address in buy function.This issue is categorised as Medium severity as it is breaking the intended functionality of etherFi contract and due to loss of ERC721 tokens or assets.
Attack Scenario\
When the
buy()
function is called by reserved buyer to purchase membership NFT by giving his t-NFT, the t-NFT can be locked or frozen with recipient address if the recipient address does not have support ofonERC721Received
support to receive the ERC721 tokens i.e T-NFT in our case.Attachments
https://github.com/hats-finance/ether-fi-0x36c3b77853dec9c4a237a692623293223d4b9bc4/blob/180c708dc7cb3214d68ea9726f1999f67c3551c9/src/NFTExchange.sol#L94
As openzeppelin recommended to use safeTransferFrom instead of transferFrom while transferring the ERC721 NFTs. We recommend same so that there should not be loss of assets of reserved buyers.
Below is the high level recommendation to resolve the issue,