Incorrect ERC721 receiver check causes safe transfers to always fail #135
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
downgraded by judge
Judge downgraded the risk level of this issue
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/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/OwnershipNFTs.sol#L73-L96
Vulnerability details
Impact
The
_onTransferReceived
function incorrectly checks the return value from theonERC721Received
function call. This causes all safe transfers to contract addresses to fail, even when the receiving contract correctly implements the ERC721 receiver interface.Proof of Concept
Take a look at the
_onTransferReceived
function: https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/OwnershipNFTs.sol#L73-L96The
require
statement checks if the returneddata
is NOT equal to theonERC721Received
selector. This is the opposite of what it should be doing. According to the ERC721 standard, theonERC721Received
function should return its function selector to indicate successful receipt of the token. but the way it's currently implemented will revert the transaction when the receiver correctly implements theonERC721Received
function.This bug goes on to affect both
safeTransferFrom
functions in the contract, as they both call_onTransferReceived
:Tools used
Manual review
Recommended Mitigation Steps
Change the
require
statement in the_onTransferReceived
function to check for equality instead of inequality:Assessed type
Error
The text was updated successfully, but these errors were encountered: