ERC1155Bridgable.sol cannot receive ETH royalties
The ERC1155Bridgable contract lacks a payable receive or fallback function, so it cannot accept ETH. As a result, royalty providers cannot send ETH to the contract, and users cannot claim their ETH royalties.
IronsideSec Follow with MohammedRizwan, OpaBatyo and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/140
Found by
Ironsidesec, MohammedRizwan, OpaBatyo, ZanyBonzy, heeze, merlin
Summary
ERC1155Bridgable.sol cannot receive ETH, so any attempts for royalty sources to send ETH to the contract will fail, and as a result, users cannot claim their ERC1155 royalties.
Vulnerability Detail
ERC1155Bridgable.sol holds the claimRoyalties function which allows users, through the INFERNAL_RIFT_BELOW to claim their royalties, ETH token or otherwise. However, when dealing with ETH, the contract has no payable receive or fallback function, and as a result cannot receive ETH. Thus, users cannot claim their ETH royalties.
function claimRoyalties(address _recipient, address[] calldata _tokens) external {
if (msg.sender != INFERNAL_RIFT_BELOW) {
revert NotRiftBelow();
}
// We can iterate through the tokens that were requested and transfer them all
// to the specified recipient.
uint tokensLength = _tokens.length;
for (uint i; i < tokensLength; ++i) {
// Map our ERC20
ERC20 token = ERC20(_tokens[i]);
// If we have a zero-address token specified, then we treat this as native ETH
if (address(token) == address(0)) {
SafeTransferLib.safeTransferETH(_recipient, payable(address(this)).balance);
} else {
SafeTransferLib.safeTransfer(token, _recipient, token.balanceOf(address(this)));
}
}
}
Impact
Contracts cannot receive ETH, and as a result, users cannot claim their royalties, leading to loss of funds.
Add the test code below to RiftTest.t.sol, and run it with forge test --mt test_bridged1155CannotReceiveETH -vvvv
function test_bridged1155CannotReceiveETH() public {
l1NFT1155.mint(address(this), 0, 1);
l1NFT1155.setApprovalForAll(address(riftAbove), true);
address[] memory collections = new address[](1);
collections[0] = address(l1NFT1155);
uint[][] memory idList = new uint[][](1);
uint[] memory ids = new uint[](1);
ids[0] = 0;
idList[0] = ids;
uint[][] memory amountList = new uint[][](1);
uint[] memory amounts = new uint[](1);
amounts[0] = 1;
amountList[0] = amounts;
mockPortalAndMessenger.setXDomainMessenger(address(riftAbove));
riftAbove.crossTheThreshold1155(
_buildCrossThreshold1155Params(collections, idList, amountList, address(this), 0)
);
Test1155 l2NFT1155 = Test1155(riftBelow.l2AddressForL1Collection(address(l1NFT1155), true));
address RoyaltyProvider = makeAddr("RoyaltyProvider");
vm.deal(RoyaltyProvider, 10 ether);
vm.expectRevert();
vm.prank(RoyaltyProvider);
(bool success, ) = address(l2NFT1155).call{value: 10 ether}("");
assert(success);
vm.stopPrank();
}
The test passes because we are expecting a reversion with EvmError as the contract cannot receive ETH. Hence there's no ETH for the users to claim.
├─ [0] VM::expectRevert(custom error f4844814:)
│ └─ ← [Return]
├─ [0] VM::prank(RoyaltyProvider: [0x5D4FfD958F2bfe55BfC8B0602A8C066E2D7eeBa8])
│ └─ ← [Return]
├─ [201] 0x094bb35C5C8E23F2A873541aDb8c5e464C29c668::fallback{value: 10000000000000000000}()
│ ├─ [45] ERC1155Bridgable::fallback{value: 10000000000000000000}() [delegatecall]
│ │ └─ ← [Revert] EvmError: Revert
│ └─ ← [Revert] EvmError: Revert
├─ [0] VM::stopPrank()
Code Snippet
Tool used
Manual Review
Recommendation
Add a payable receive function to the contract.
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 contract lacks a payable receive or fallback function, so it cannot accept native ETH transfers.
Impact
Users cannot claim their ETH royalties, leading to a loss of funds for those users.
What the attacker needed
The contract is deployed; A royalty source attempts to send ETH
The fix
Add a payable receive function to the contract so it can accept ETH.
How it was found
- Deploy the contracts and set up the bridge.
- Mint an NFT and approve the bridge to transfer it.
- Bridge the NFT to the L2 contract.
- Attempt to send ETH to the L2 ERC1155 contract.
- Observe that the transaction reverts because the contract cannot receive ETH.
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 smart contract is supposed to hold ETH royalties for users to claim later. But the contract has no way to accept ETH sent to it, so any ETH transfer to it fails. That means the royalties never arrive and users cannot claim them.
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.