Currently the bridge makes assumptions about a collection's tokenURI(uint256)
implementation that do not necessarily hold, causing L2 to mint NFTs with wrong token_uri
s.
The bridge currently assumes that for a collections either a baseURI
OR a tokenURI
is set. More specifically, it assumes the following:
if baseURI
is set, the tokenURI
looks like baseURI::tokenId
if no baseURI
is set, the tokenURI
looks like tokenURI
This holds in many cases but is not necessarily the case. If we look at EIP-721
, the following is written about tokenURI
:
Here we see, that the EIP
does not specify the URI
more than to be RFC 3986
conform.
This means that we can have a NFT collections where we have a baseURI
(e.g. http://example.com/
) and individual tokenURIs
(e.g. token1
, token2
...) where tokenURI()
will return a URI with the format baseURI::tokenURI
.
If we now call tokenURI(1)
we would expect it to return http://example.com/token1
as the URI.
As I pointed out above, the assumption of tokenURI
being baseURI::tokenId
or tokenURI
does not hold here as we have both a common baseURI
and also individual tokenURIs
.
If we now look at TokenUtil::erc721Metadata
, we can see that if our collection has a baseURI
(retrieved by _callBaseUri
), we return (c.name(), c.symbol(), _baseUri, [])
, therefore the tokenURIs
array is empty.
When this request is now received on L2 it is missing crucial information about our individual tokenURIs
causing it to mint our NFTs with incorrect URIs
.
This means that if we bridge our NFT with the URI http://example.com/token1
from L1 to L2, it will have the URI http://example.com/1
on L2, meaning we cannot retrieve its metadata as its URI is corrupted.
Manual review
In order to always use the proper metadata of a bridged collection/NFT I would recommend changing TokenUtil::erc721Metadata
to take into consideration the case where a baseURI
and individual tokenURIs
exist.
It is also necessary to change the code on L2 accordingly.
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.