Skip to content
Business logic Audit finding Intermediate

HolographERC721.safeTransferFrom not compliant with EIP-721

The safeTransferFrom implementation in HolographERC721 required the receiving contract to advertise ERC-165 support before calling onERC721Received, which the EIP-721 specification does not require. As a result, transfers to receivers that implement only onERC721Received, which is most receivers in practice, would revert and the tokens could not be delivered.

Lambda Follow

Originally disclosed on Code4rena

Submitted by Lambda

HolographERC721.sol#L366

According to EIP-721, we have the following for safeTransferFrom:

///  (...) When transfer is complete, this function
///  checks if `_to` is a smart contract (code size > 0). If so, it calls
///  `onERC721Received` on `_to` and throws if the return value is not
///  `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.

According to the specification, the function must therefore always call onERC721Received, not only when it has determined via ERC-165 that the contract provides this function. Note that in the EIP, the provided interface for ERC721TokenReceiver does not mention ERC-165. For the token itself, we have: interface ERC721 /* is ERC165 */ { However, for the receiver, the provided interface there is just: interface ERC721TokenReceiver { This leads to failed transfers when they should not fail, because many receivers will just implement the onERC721Received function (which is sufficient according to the EIP), and not supportsInterface for ERC-165 support.

Proof Of Concept

Let’s say a receiver just implements the IERC721Receiver from OpenZeppelin: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/IERC721Receiver.sol Like the provided interface in the EIP itself, this interface does not derive from EIP-165. All of these receivers (which are most receivers in practice) will not be able to receive those tokens, because the require statement (that checks for ERC-165 support) reverts.

Recommended Mitigation Steps

Remove the ERC-165 check in the require statement (like OpenZeppelin does: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L436).

alexanderattar (Holograph) commented:

This will be updated to be fully ERC721 compliant

ACC01ADE (Holograph) linked a PR:

Feature/HOLO-605: C4 medium risk fixes


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

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 contract gated the onERC721Received callback behind an ERC-165 supportsInterface check, which EIP-721 does not require for receivers.

Impact

Transfers of these tokens to compliant receiver contracts that do not implement ERC-165 would revert, so tokens could not be delivered to most receivers in practice.

What the attacker needed

A receiver contract that lacks ERC-165 support

The fix

The ERC-165 check in the require statement should be removed so that onERC721Received is always called, and the project said it would be updated to be fully ERC721 compliant.

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.

A non-fungible token (NFT) contract can send a token to another contract, and the standard says the sender must ask the receiving contract whether it is happy to accept the token. This report says the Holograph contract added an extra check that the receiver must first announce it supports a particular interface, which the standard does not ask for. Because most receivers do not make that announcement, the transfer is refused even though the receiver would have accepted the token.

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.

More by Lambda

View all

64 more disclosed reports, best first.

More from Holograph contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.