Use safeTransferFrom for ERC721 #136
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate
This issue or pull request already exists
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L199
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L295
https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L344
Vulnerability details
Use safeTransferFrom for ERC721
In the contract
Cally.sol
every transfer of ERC721 are done with thetransferFrom()
instead of the recommendedsafeTransferFrom()
. ThistransferFrom()
does not check, whether the receiver is capable of proper handling of NFTs.Impact
If the buyers of a call option with a ERC721 collateral is a smart contract (could be a multisig wallet) which does not implement the
onERC721Received
and do not have proper handling of ERC721 tokens, then the NFT would be lost if the option is exercised.Proof of concept
Alice creates a vault with a BAYC NFT
SomeDAO choose to buy the call option from their multisig wallet
SomeDAO exercises the option when there is a change of making a profit
The BAYC NFT is transferred to SomeDAO’s multisig wallet, but by a mistake the wallet does not support handling of ERC721 tokens.
SomeDAO have no way of retrieving the BAYC NFT, and has hence paid for a NFT they cannot get.
Even though the scenario is unlikely, and it would be the users own fault, there is no doubt that when it requires so small an effort, it makes sense to make it impossible to do this rooky mistake.
A similar issue was also scored as a medium see here.
The relevant code:
L199, L295, and L344.
Recommended mitigation
It is recommended to use the safe version
safeTransferFrom()
since this will require the receiving contract to implementIERC721Receiver.onERC721Received
The text was updated successfully, but these errors were encountered: