NFTBridge
60,000 USDC
View results
Submission Details
Severity: high
Valid

Too many whitelisted collections will permanently brick withdrawing native L2 NFT on the Solidity L1 bridge

Every collection whitelisted will add to _collections array. If the _collections array is too huge, _whiteListCollection will fail because the while loop that iterates over the _collections array will exceed block gas limit.

function _whiteListCollection(address collection, bool enable) internal {
if (enable && !_whiteList[collection]) {
bool toAdd = true;
uint256 i = 0;
while(i < _collections.length) {
if (collection == _collections[i]) {
toAdd = false;
break;
}
i++;
}
if (toAdd) {
_collections.push(collection);
}
}
_whiteList[collection] = enable;
}

This function is called if the NFT is native L1 token, therefore a new collection L1 has to be deployed which will cause _whiteListCollection to be called.

if (collectionL1 == address(0x0)) {
if (ctype == CollectionType.ERC721) {
collectionL1 = _deployERC721Bridgeable(
req.name,
req.symbol,
req.collectionL2,
req.hash
);
// update whitelist if needed
_whiteListCollection(collectionL1, true);
} else {
revert NotSupportedYetError();
}
}

So if there are too many collections whitelisted it can result in loss of native L2 NFT when withdrawing from L1 bridge as it won't be possible to whitelist the collection (due to exceed block gas limit)

Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-collections-always-withelisted-on-both-chain-withdraw-impossible-collections-array-will-be-OOG

Likelyhood: High, once the whitelist option is disabled, collections will grow. Impact: High, withdraw won’t be possible because of Out-Of-Gas.

Support

FAQs

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