Inverted Selector Check Causes All ERC721 Safe Transfers to Contract Addresses to Fail #81
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-148
🤖_09_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/main/pkg/sol/OwnershipNFTs.sol#L73
Vulnerability details
Summary
There is a critical bug in the
_onTransferReceived
function. The function incorrectly checks the return value from theonERC721Received
callback, causing all safe transfers to contract addresses to fail, even when the receiving contract correctly implements the ERC721 receiver interface.Code Snippet
https://github.com/code-423n4/2024-08-superposition/blob/main/pkg/sol/OwnershipNFTs.sol#L73
The bug is in the
require
statement. It's checking if the returned data is NOT equal to the expected selector, which is the opposite of what it should do.Impact
onERC721Received
.Scenario
safeTransferFrom
.onERC721Received
and returns the expected selector.require
statement in_onTransferReceived
reverts the transaction.Fix
The fix is to change the
!=
operator to==
in therequire
statement:This change ensures that the function only proceeds if the receiving contract returns the correct selector, indicating it can handle ERC721 tokens.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: