ERC1155 cannot claim royalities on L2
The royalty claim function on L2 only supports ERC721 collections because it checks deployment using a flag set to false, causing ERC1155 collections to revert. As a result, owners of ERC1155 collections cannot claim their royalties, leading to a loss of expected income.
Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/456
Found by
0xdice91, BugPull, OpaBatyo, Ruhum, Thanos, h2134, heeze, novaman33, zzykxx
Summary
The royalty claim function is designed to allow owners of collections deployed on L2 to claim their royalties on L1. However, this function only supports collections using the ERC721 standard. If the collection is an ERC1155, the function reverts due to a check in isDeployedOnL2, preventing the owner from claiming their royalties.
Vulnerability Detail
The function claimRoyalties checks if a collection is deployed on L2 using the isDeployedOnL2 function. This check only passes if the collection is an ERC721 standard. When an ERC1155 collection is used as the _collectionAddress, the function reverts because the check fails. As a result, owners of ERC1155 collections are unable to claim their royalties.
NOTE: The ERC1155Bridgable contract implements claimRoyalty function: https://github.com/sherlock-audit/2024-08-flayer/blob/main/moongate/src/libs/ERC1155Bridgable.sol#L104-L135
POC:
// on L1
function claimRoyalties(address _collectionAddress, address _recipient, address[] calldata _tokens, uint32 _gasLimit) external {
//...
@>>> ICrossDomainMessenger(L1_CROSS_DOMAIN_MESSENGER).sendMessage(
INFERNAL_RIFT_BELOW,
abi.encodeCall(IInfernalRiftBelow.claimRoyalties, (_collectionAddress, _recipient, _tokens)),
_gasLimit
);
//...
}
// on L2
function claimRoyalties(address _collectionAddress, address _recipient, address[] calldata _tokens) public {
// Ensure that our message is sent from the L1 domain messenger
if (ICrossDomainMessenger(msg.sender).xDomainMessageSender() != INFERNAL_RIFT_ABOVE) {
revert CrossChainSenderIsNotRiftAbove();
}
// Get our L2 address from the L1
@>>> // revert will happen here because passing ERC1155 _collectionAddress with false to isDeployedOnL2
// will check if ERC721Bridgable is deployed not ERC1155Bridgable.
// so calling claimRoyalties will cause revert.
@>>> if (!isDeployedOnL2(_collectionAddress, false)) revert L1CollectionDoesNotExist();
// Call our ERC721Bridgable contract as the owner to claim royalties to the recipient
ERC721Bridgable(l2AddressForL1Collection(_collectionAddress, false)).claimRoyalties(_recipient, _tokens);
emit RoyaltyClaimFinalized(_collectionAddress, _recipient, _tokens);
}
Impact
the inability of ERC1155 owners to claim royalties results in a loss of expected income for the collection owners.
Recommendation
add logic to handle ERC1155 _collectionAddress.
function claimRoyalties(address _collectionAddress, address _recipient, address[] calldata _tokens) public {
// Ensure that our message is sent from the L1 domain messenger
if (ICrossDomainMessenger(msg.sender).xDomainMessageSender() != INFERNAL_RIFT_ABOVE) {
revert CrossChainSenderIsNotRiftAbove();
}
// Get our L2 address from the L1
+ if (isDeployedOnL2(_collectionAddress, false)) {
+ // Call our ERC721Bridgable contract as the owner to claim royalties to the recipient
+ ERC721Bridgable(l2AddressForL1Collection(_collectionAddress, false)).claimRoyalties(_recipient, _tokens);
+ emit RoyaltyClaimFinalized(_collectionAddress, _recipient, _tokens);
+ }
+ else if (isDeployedOnL2(_collectionAddress, true)) {
+ // Call our ERC1155Bridgable contract as the owner to claim royalties to the recipient
+ ERC1155Bridgable(l2AddressForL1Collection(_collectionAddress, true)).claimRoyalties(_recipient, _tokens);
+ emit RoyaltyClaimFinalized(_collectionAddress, _recipient, _tokens);
+ }
+ else {
+ revert L1CollectionDoesNotExist();
+ }
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The claimRoyalties function hardcodes the isDeployedOnL2 check to only look for ERC721 collections, ignoring ERC1155 collections.
Impact
Owners of ERC1155 collections are unable to claim their royalties, resulting in a loss of expected income.
What the attacker needed
Collection is ERC1155; collection deployed on L2; owner initiates royalty claim
The fix
The function should be updated to check for both ERC721 and ERC1155 deployments and call the appropriate bridgable contract for each.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report is about a smart contract system that lets people claim royalties (payments for secondary sales) across two blockchains. The claim function only works for one type of digital collectible (ERC721) and fails for another type (ERC1155), so owners of the second type cannot get their money.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.