Skip to content
Smart contracts Audit finding Beginner

Using `ERC721.transferFrom()` instead of `safeTransferFrom()` may cause the user's NFT to be frozen in a contract that does not support ERC721

The unstake function uses transferFrom instead of safeTransferFrom, so if a user specifies a recipient contract that cannot handle ERC721 tokens, the NFT becomes stuck in that contract. An attacker could cause a user's NFT to be frozen by tricking them into unstaking to such a contract.

WatchPug Follow with Nyx, saian and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-frankendao-judging/issues/55

Found by

WATCHPUG, Nyx, saian, rvierdiiev, Bnke0x0, Tomo

Summary

There are certain smart contracts that do not support ERC721, using transferFrom() may result in the NFT being sent to such contracts.

Vulnerability Detail

In unstake(), _to is param from user's input.

However, if _to is a contract address that does not support ERC721, the NFT can be frozen in that contract.

As per the documentation of EIP-721:

A wallet/broker/auction application MUST implement the wallet interface if it will accept safe transfers.

Ref: https://eips.ethereum.org/EIPS/eip-721

Impact

The NFT may get stuck in the contract that does support ERC721.

Code Snippet

https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L463-L489

Tool used

Manual Review

Recommendation

Consider using safeTransferFrom() instead of transferFrom().

Discussion

zobront

Fixed: https://github.com/Solidity-Guild/FrankenDAO/pull/10

jack-the-pug

Fix confirmed

The original report as published on Sherlock, by WATCHPUG. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 code uses transferFrom instead of safeTransferFrom, so it does not verify that the recipient contract can handle ERC721 tokens.

Impact

The NFT may get stuck in a contract that does not support ERC721, making it permanently frozen.

What the attacker needed

User unstakes to a contract address; contract does not support ERC721

The fix

The issue was fixed by switching to safeTransferFrom.

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 you send an NFT to a contract, the contract needs a way to recognise and handle it. The safe transfer function checks this; the plain transfer function does not. If you use the plain one, the NFT can get stuck forever in a contract that cannot deal with it.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by WatchPug

View all

197 more disclosed reports, best first.

More from FrankenDAO

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.