Use safeTransferFrom Instead of transferFrom for ERC721
The contract moved ERC721 tokens with transferFrom rather than safeTransferFrom, so it never checked whether the receiving address could handle NFTs. If the recipient was a contract that does not implement the receiver hook, the token could become permanently stuck there.
Submitted by TomJ, also found by 141345, _Adam, 0x4non, 0x52, 0xDjango, 0xf15ers, 0xNazgul, 0xsanson, 8olidity, apostle0x01, arcoun, benbaessler, bin2chen, Bnke0x0, brgltd, cccz, CertoraInc, Ch_301, Chom, cloudjunky, cryptonue, djxploit, Dravee, ellahi, erictee, GalloDaSballo, GimelSec, hansfriese, i0001, JC, Jujic, Kenshin, Kumpa, Lambda, M0ndoHEHE, minhquanym, oyc_109, PaludoX0, peritoflores, rbserver, reassor, RedOneN, rokinot, rotcivegaf, Ruhum, saian, shenwilly, Sm4rty, sseefried, Treasure-Seeker, TrungOre, Twpony, and Waze
Use of transferFrom method for ERC721 transfer is discouraged and recommended to use safeTransferFrom whenever possible by OpenZeppelin.
This is because transferFrom() cannot check whether the receiving address know how to handle ERC721 tokens.
In the function shown at below PoC, ERC721 token is sent to msg.sender with the transferFrom method.
If this msg.sender is a contract and is not aware of incoming ERC721 tokens, the sent token could be locked up in the contract forever.
Reference: https://docs.openzeppelin.com/contracts/3.x/api/token/erc721
Proof of Concept
GolomTrader.sol:236: ERC721(o.collection).transferFrom(o.signer, receiver, o.tokenId);
Recommended Mitigation Steps
I recommend to call the safeTransferFrom() method instead of transferFrom() for NFT transfers.
0xsaruman (Golom) confirmed, but disagreed with severity
0xsaruman (Golom) resolved and commented:
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
Likely the transfer helper was called without the safe variant, so no check was made that the receiving contract implements the ERC721 receiver interface.
Impact
An NFT could be locked forever in a receiving contract that cannot handle ERC721 tokens; the report does not claim theft or loss for ordinary wallet recipients.
What the attacker needed
Recipient is a contract; recipient cannot handle ERC721 tokens
The fix
The transfer should call safeTransferFrom instead of transferFrom, and the project says it was resolved.
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.
An NFT is a token that lives on a blockchain. When a contract sends one, it can use a plain transfer or a 'safe' transfer. The safe version first asks the receiver whether it knows how to accept NFTs; the plain version does not, so an NFT sent to a contract that cannot handle it may be stuck there with no way to get it back.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.