Submitted by IllIllI, also found by rotcivegaf and Ruhum
veNFTs may be sent to contracts that cannot handle them, and therefore all rewards and voting power, as well as the underlying are locked forever
The original code had the following warning:
ve.sol#L143-L144
The minting code, which creates the locks, does not do this check:
VotingEscrow.sol#L462-L472
Once a lock is already minted, if its transfered to a contract, the code does attempt to check for the issue:
VotingEscrow.sol#L378-L406
While the transfer function does in fact execute onERC721Received, it doesnt actually do a check of the bytes4 variable - it only checks for a non-zero length. The ERC721 standard says that for the function call to be valid, it must return the bytes4 function selector, otherwise its invalid. If a user of the escrow system uses a contract that is attempting to explicitly reject NFTs by returning zero in its onERC721Received() function, the VotingEscrow will interpret that response as success and will transfer the NFT, potentially locking it forever. If the lock is minted to a contract, no checks are done, and the NFT can be locked forever.
Call onERC721Received() in _mint() and ensure that the return value equals IERC721Receiver.onERC721Received.selector in both _mint() and safeTransferFrom().
pooltypes (Velodrome) disputed
Alex the Entreprenerd (judge) commented:
