-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bytes data
param is not passed to ERC721 recipient as expected by EIP-721
#146
Comments
alex-ppg changed the severity to QA (Quality Assurance) |
alex-ppg marked the issue as grade-c |
hi @alex-ppg, i will like implore you to review your decision on this finding as it is quite different from the findings it was grouped with. This finding does not just talk about EIP-721 compliance but spotlights an implementation flaw in the callback to the token receiver. The hardcoding of the empty bytes passed to the token receiver when the receiver is a contract obstructs the usecase of the ERC721Receiver callback/hook . The usecases of this hooks are
The OwnershipNFT as it is prevents usecases 2 and 3 and in some cases will may prevent 1 because if a contract that has custom logic which requires bytes to be passed in, it will never be ready to receive the token. Bytes data passed in by a token sender should be propagated to the token receiver contracts. This is the correct, expected and complete implementation of |
Hey @adeolu98, thank you for your PJQA contribution! Indeed, this finding seems to have been grouped incorrectly during the validation phase. Per the rationale laid out in #55, the EIP-721 callback feature was deliberately implemented and does not forward the A medium severity rating for this submission similar to #55 is appropriate. |
This previously downgraded issue has been upgraded by alex-ppg |
alex-ppg marked the issue as not a duplicate |
alex-ppg marked the issue as selected for report |
alex-ppg marked the issue as satisfactory |
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/sol/OwnershipNFTs.sol#L148-L157
Vulnerability details
Bug Description
ERC-721 standard has two variations of the
safeTransferFrom()
, one with nobytes data
param and the other with abytes data
param. The second variation that accepts abytes data
param is meant to pass that data param to the token recipient during theIERC721TokenReceiver. onERC721Received()
call. Thisbytes data
param is usually an encoding of extra variables which is used by the recipient contract for the extra logic it will perform as it receives a token.OwnershipNFTs.sol is ERC721 compliant and so it has two
safeTransferFrom()
functions but the secondsafeTransferFrom()
has abytes data
param which is not passed into the recipient duringIERC721TokenReceiver. onERC721Received()
call to recipient. It accepts thebytes data
param but doesnt use it.As we can see above the bytes param is declared as an arbitrary param, perhaps just to conform to IERC721 spec but the bytes param is not used in the logic at all, and it ought to be used as defined here in the EIP.
For contracts that integrate OwnershipNFTs or receive transfers, if they have logic which require the additional bytes passed in via the second
safeTransferFrom()
, they will be unable to execute this logic and may reject the transfers or revert as thisbytes data
supplied by the caller of thesafeTransferFrom()
is not passed into them via theIERC721TokenReceiver.onERC721Received()
call. Instead, empty bytes is passed intoIERC721TokenReceiver.onERC721Received()
as seen here.Below is a POC which shows how passing empty bytes by default instead of passing the bytes specified by the sender into a tokenReceiver may cause the transfer to fail.
forge test
Impact
the implementation of the
safeTransferFrom()
function that accepts additional bytes is not sufficient and not as defined by the EIP-721 spec. The bytes param passed in by a caller is not sent to the recipient contract. Receiving contracts may need to decode this bytes param, but since empty bytes are passed in to recipient by default in OwnershipNfts this will cause reverts/inaccessibility to this function/feature of the ERC721Tools Used
manual review
Recommended Mitigation Steps
The issue stems from the _onTransferReceived() not accepting a
bytes data
param. Modify it to accept it and pass that param into theIERC721TokenReceiver.onERC721Received()
call. Then in each safeTransferFrom(), pass the bytes param into the modified_onTransferReceived()
. If the safeTransferFrom() accepts no bytes param, pass empty bytes into_onTransferReceived()
Assessed type
ERC721
The text was updated successfully, but these errors were encountered: