Skip to content
Smart contracts Audit finding Intermediate

`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_URI extension can be identified with the ERC-165 Standard Interface Detection.

If the optional ERC1155Metadata_URI extension is included:

  • The ERC-165 supportsInterface function MUST return the constant value true if 0x0e89341c is passed through the interfaceID argument.
  • Changes to the URI MUST emit the URI event if the change can be expressed with an event (i.e. it isn’t dynamic/programmatic).

But we see that:

Solidity
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:

Solidity
// 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.

The original report as published on Sherlock, by ComposableSecurity. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More by ComposableSecurity

View all

6 more disclosed reports, best first.

More from Flayer

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.