`ERC1155Bridgable` is not EIP-1155 compliant
The ERC1155Bridgable contract does not emit the required URI event when a token's URI is changed via setTokenURIAndMintFromRiftAbove, violating the EIP-1155 standard. This could cause integrating protocols that rely on the event to work incorrectly.
ComposableSecurity Follow with Spearmint and kuprum
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/202
The protocol has acknowledged this issue.
Found by
ComposableSecurity, Spearmint, kuprum
Summary
According to the README:
The Bridged1155 should be strictly compliant with EIP-1155 and EIP-2981
EIP-1155 states the following about ERC1155Metadata_URI extension:
The optional
ERC1155Metadata_URIextension can be identified with the ERC-165 Standard Interface Detection.If the optional
ERC1155Metadata_URIextension is included:
- The ERC-165
supportsInterfacefunction MUST return the constant valuetrueif0x0e89341cis passed through theinterfaceIDargument.- Changes to the URI MUST emit the
URIevent if the change can be expressed with an event (i.e. it isn’t dynamic/programmatic).
But we see that:
ERC1155Bridgabledoes support the extension, and returns the required constant via supportsInterface- It does not emit the
URIevent as required, when it's changed via function setTokenURIAndMintFromRiftAbove:
function setTokenURIAndMintFromRiftAbove(uint _id, uint _amount, string memory _uri, address _recipient) external {
if (msg.sender != INFERNAL_RIFT_BELOW) {
revert NotRiftBelow();
}
// Set our tokenURI
uriForToken[_id] = _uri;
// Mint the token to the specified recipient
_mint(_recipient, _id, _amount, '');
}
Notice that when bridging the ERC-1155 tokens, URIs are retrieved from the corresponding token contract by InternalRiftAbove, and encoded into the package as follows:
// Go through each NFT, set its URI and escrow it
uris = new string[](numIds);
for (uint j; j < numIds; ++j) {
// Ensure we have a valid amount passed (TODO: Is this needed?)
tokenAmount = params.amountsToCross[i][j];
if (tokenAmount == 0) {
revert InvalidERC1155Amount();
}
uris[j] = erc1155.uri(params.idsToCross[i][j]);
erc1155.safeTransferFrom(msg.sender, address(this), params.idsToCross[i][j], params.amountsToCross[i][j], '');
}
// Set up payload
package[i] = Package({
chainId: block.chainid,
collectionAddress: collectionAddress,
ids: params.idsToCross[i],
amounts: params.amountsToCross[i],
uris: uris,
royaltyBps: _getCollectionRoyalty(collectionAddress, params.idsToCross[i][0]),
name: '',
symbol: ''
});
I.e. the information is properly retrieved, transferred, and is available; but the URI event is not emitted as required; this breaks the specification.
Impact
Protocols integrating with ERC1155Bridgable may work incorrectly.
Mitigation
Compare the URI supplied for an NFT in function setTokenURIAndMintFromRiftAbove, and if it has changed -- emit the URI event as required per the specification.
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
Impact
Protocols integrating with ERC1155Bridgable may work incorrectly because they do not receive the URI change notification.
What the attacker needed
None
The fix
The contract should compare the new URI with the previous one and emit the URI event if it has changed.
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.
ERC-1155 is a standard for blockchain tokens that can represent many types of items. The standard says that if a token's web address (URI) changes, the contract must announce this with an event so other programs can react. This contract changes the URI without making that announcement, which breaks the standard and may confuse other programs.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.