The TokenUtil
library has incomplete functionality for retrieving metadata from ERC1155 tokens and potential issues in handling base URI retrieval using low-level assembly code. These vulnerabilities can lead to missing or incorrect metadata, impacting the utility and reliability of the library.
1.Incomplete ERC1155 Metadata Retrieval:
Description: The erc1155Metadata
function in the TokenUtil
library always returns an empty string, failing to retrieve any metadata for ERC1155 tokens.
2.Base URI Handling in _callBaseUri
:
Description: The _callBaseUri
function uses low-level assembly to call _baseUri
or baseUri
functions. If the return value is not handled correctly, it may incorrectly assume that the base URI is not present.
forge test --match-path test/TokenUtilTest.t.sol -vvvv
[⠊] Compiling...
No files changed, compilation skipped
Ran 2 tests for test/TokenUtilTest.t.sol:TokenUtilTest
[PASS] testCallBaseUriReturnValue() (gas: 82245)
Traces:
[82245] TokenUtilTest::testCallBaseUriReturnValue()
├─ [47299] → new MockERC721WithValidBaseUri@0xF62849F9A0B5Bf2913b396098F7c7019b51A820a
│ └─ ← [Return] 236 bytes of code
├─ [439] MockERC721WithValidBaseUri::_baseUri() [staticcall]
│ └─ ← [Return] "https://example.com/"
└─ ← [Stop]
[PASS] testERC1155Metadata() (gas: 941)
Traces:
[941] TokenUtilTest::testERC1155Metadata()
└─ ← [Stop]
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 971.60µs (283.10µs CPU time)
Ran 1 test suite in 891.69ms (971.60µs CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
Users cannot retrieve metadata for ERC1155 tokens, limiting the functionality and utility of the library. This can affect applications relying on this metadata for display or processing purposes.
Incorrect handling of the base URI can lead to missing or incorrect metadata. This can cause issues in applications that depend on accurate metadata for ERC721 tokens.
Manual review
Foundry
Implement the erc1155Metadata
function to properly retrieve and return metadata for ERC1155 tokens. Consider using the IERC1155MetadataURI
interface to fetch the URI for a sample token and extract the base URI.
Ensure that the return value is correctly decoded and handled. Avoid relying solely on the return size and value checks.
```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(); } … } ```
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.