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

Incorrect `base_uri` will lead to incomplete metadata (`collection_manager::erc721_metadata`)

Summary

Vulnerability Detail

The erc721_metadata function of the collection_manager.cairo contract is responsible for extracting metadata from a given ERC721 contract. This function constructs an ERC721Metadata struct, which includes fields such as name, symbol, base_uri, and uris. The base_uri field is crucial as it typically forms the base part of the URI for token metadata.

In the current implementation, the base_uri is hardcoded to an empty string (""). This is problematic because the base_uri should be retrieved from the ERC721 contract to ensure the metadata is complete and accurate. By setting it to an empty string, the function returns incomplete metadata, which can lead to issues for applications relying on this data.

Relevant code snippet:

Option::Some(
ERC721Metadata {
name: erc721.name(),
symbol: erc721.symbol(),
base_uri: "", // @audit - Incorrectly set to an empty string
uris
}
)

Impact

The impact of this issue is that any application or user relying on the erc721_metadata function to retrieve metadata will receive incomplete information. Specifically, the base_uri will always be an empty string, which can lead to incorrect or missing metadata URIs. This can cause confusion and potential issues in applications that depend on accurate metadata, such as NFT marketplaces or wallets.

Proof of Concept

  1. A user calls the erc721_metadata function with a valid contract_address and an optional list of token_ids.

  2. The function constructs the ERC721Metadata struct.

  3. The base_uri field is set to an empty string (""), regardless of the actual base URI of the ERC721 contract.

  4. The function returns the ERC721Metadata struct with an incorrect base_uri.

Tools Used

Manual review

Recommendation

To fix this issue, the base_uri should be retrieved from the ERC721 contract, similar to how name and symbol are retrieved. Here is the recommended code change:

Option::Some(
ERC721Metadata {
name: erc721.name(),
symbol: erc721.symbol(),
base_uri: erc721.base_uri(), // Retrieve base_uri from the contract
uris
}
)

This change ensures that the base_uri field in the ERC721Metadata struct contains the correct value from the ERC721 contract, providing complete and accurate metadata.

Updates

Lead Judging Commences

n0kto Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

invalid-NFT-minted-without-baseURI-URIs-or-bridge-with-no-metadata

URI is not lost on the origin chain and it can be modified with `ERC721UriImpl`. As explained in the TODO  below, that’s a design choice and it will be implemented as a future feature. https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/ethereum/src/Bridge.sol#L206 `ERC721Bridgable` is out of scope.

Support

FAQs

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