Open code423n4 opened 1 year ago
We accept it. This should be Low severity.
We will see if there is a more interesting place where to send the royalties instead of returning address(0) in this case.
donosonaumczuk marked the issue as disagree with severity
Unless I have missed it I don't see in the EIP that this function shouldn't revert, so it's more an issue at the marketplace level and a QA comment in the context of this contest in my opinion
Picodes changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/main/contracts/misc/LegacyCollectNFT.sol#L102-L106 https://github.com/code-423n4/2023-07-lens/blob/main/contracts/FollowNFT.sol#L449-L453
Vulnerability details
Bug Description
Contracts that inherit
ERC2981CollectionRoyalties
must override_getReceiver()
to determine the royalty recipient returned byroyaltyInfo()
.For
LegacyCollectNFT.sol
andFollowNFT.sol
,_getReceiver()
returns the owner of_profileId
and_followedProfileId
respectively:LegacyCollectNFT.sol#L102-L106
FollowNFT.sol#L449-L453
However, the
ownerOf()
function in Openzeppelin's ERC-721 implementation reverts when the token has no owner:ERC721.sol#L70-L74
As such, profile owners can burn their profile through the
burn()
function inLensProfiles.sol
to forceroyaltyInfo()
to revert.This becomes problematic in NFT marketplaces that support ERC-2981 and call
royaltyInfo()
without handling reverts gracefully. For example, the Caviar NFT Marketplace callsroyaltyInfo()
whenever NFTs are bought or sold:CaviarEthRoyaltyRouter.sol#L150-L152
Therefore, whenever a collect or follow NFT is bought through the NFT marketplace, the profile owner can burn his profile to DOS the swap, and potentially cause the NFT to become stuck in the contract.
Impact
In
LegacyCollectNFT.sol
andFollowNFT.sol
,royaltyInfo()
will revert when the corresponding profile is burned. This might break the functionality of contracts that make calls toroyaltyInfo()
, but do not expect it to revert.Proof of Concept
The following Foundry test demonstrates that
royaltyInfo()
reverts after the corresponding profile has been burnt. It can be run using the following command:Recommended Mitigation
Consider checking if the profile exists first and returning
address(0)
immediately if it doesn't:LegacyCollectNFT.sol#L102-L106
FollowNFT.sol#L449-L453
Assessed type
DoS