NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Attackers can bypass ERC1155 metadata checks in `TokenUtil::erc1155Metadata()`

Summary

Vulnerability Detail

The TokenUtil library provides utility functions for handling different token standards, including ERC721 and ERC1155. One of its key functions is erc1155Metadata(), which is intended to retrieve metadata from ERC1155 tokens. However, the current implementation of this function is severely flawed, potentially allowing attackers to bypass important checks and manipulate the metadata retrieval process.

The erc1155Metadata() function is designed to check if a given collection address supports the ERC1155 metadata interface and then return the appropriate metadata. However, the current implementation always returns an empty string, regardless of the input:

function erc1155Metadata(
address collection
)
internal
view
returns (string memory)
{
return "";
// ... commented out code ...
}

This implementation effectively nullifies any checks or validations that should be performed on the ERC1155 token contract. As a result, any system relying on this function to validate or retrieve ERC1155 metadata will receive an empty string, potentially leading to incorrect assumptions about the token's properties or capabilities.

Impact

The impact of this issue is significant. Systems relying on the erc1155Metadata() function to validate or retrieve ERC1155 token metadata will receive no useful information, potentially leading to:

  1. Incorrect validation of ERC1155 tokens, allowing non-compliant or malicious contracts to be treated as valid ERC1155 tokens.

  2. Failure to retrieve essential metadata, which could affect token display, functionality, or integration with other systems.

Tools Used

Manual review

Recommended Mitigation Steps

The erc1155Metadata() function should be properly implemented to perform the necessary checks and retrieve the actual metadata. Here's a suggested fix:

function erc1155Metadata(
address collection,
uint256 tokenId
)
internal
view
returns (string memory)
{
bool supportsMetadata = ERC165Checker.supportsInterface(
collection,
type(IERC1155MetadataURI).interfaceId
);
if (!supportsMetadata) {
return "";
} else {
IERC1155MetadataURI metadataContract = IERC1155MetadataURI(collection);
return metadataContract.uri(tokenId);
}
}

This implementation:

  1. Checks if the contract supports the IERC1155MetadataURI interface.

  2. If supported, it retrieves and returns the URI for the specified token ID.

  3. If not supported, it returns an empty string, maintaining the current behavior for non-compliant contracts.

Updates

Lead Judging Commences

n0kto Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
Assigned finding tags:

invalid-ERC1155-not-in-scope

```compatibilities: Blockchains: - Ethereum/Starknet Tokens: - [ERC721](www.tokenstandard.com) ``` ``` function depositTokens( uint256 salt, address collectionL1, snaddress ownerL2, uint256[] calldata ids, bool useAutoBurn ) external payable { if (!Cairo.isFelt252(snaddress.unwrap(ownerL2))) { revert CairoWrapError(); } if (!_enabled) { revert BridgeNotEnabledError(); } CollectionType ctype = TokenUtil.detectInterface(collectionL1); if (ctype == CollectionType.ERC1155) { @> revert NotSupportedYetError(); } … } ```

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.