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

All nfts using the bridge will always be permissioned

Github links

solidity

https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/ethereum/src/Bridge.sol#L368-L375
https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/ethereum/src/token/CollectionManager.sol#L138-L141

cairo

https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/starknet/src/bridge.cairo#L360-L364
https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/starknet/src/token/collection_manager.cairo#L189-L196

Summary

Whitelist can't be disabled because the setL1L2CollectionMapping and set_l1_l2_collection_mapping will always act as a form of whitelist. This means all nfts using the bridge will always be permissioned.

Vulnerability Details

Assuming the bridge is permissionless, and you own everai nft#1337 and you decide to bridge from l1 -> l2, it would work fine. However, if you try to bridge back from l2 -> l1, this check in the _verifyRequestAddresses will fail

if (l2Req > 0 && l1Req > address(0)) {
if (l1Mapping != l1Req) {
revert InvalidCollectionL1Address();
} else if (l2Mapping != l2Req) {
// @audit: failure happens here because the l2Mapping address will be zero
revert InvalidCollectionL2Address();
} else {
return l1Mapping;
}
}

the l1 bridge contract will never know the l2 address of a native l1 nft. The same is true for native l2 nfts when you try to do l2 -> l1 -> l2 bridge transactions. The l2 bridge will not know the l1 address and the verify_collection_address function will fail. This is unless of course the setL1L2CollectionMapping (Bridge.sol) function or set_l1_l2_collection_mapping (bridge.cairo) function is called by an admin.

this means that even if the enable_whitelist_function(false) is called, the set collection mappings functions would still necessarily act as a form of whitelist.

Impact

Bridge will always need to whitelist nfts

Recommendations

During a bridge transaction from l1 to l2 and vice versa, we can trust that the req.collectionL1 and req.collectionL2are correct because the bridges only communicate with each other. so there should be no check that l1Mapping == l1Req or l2Mapping == l2Req in both bridge contracts.

Then the setL1L2CollectionMapping and set_l1_l2_collection_mapping can be removed.

Updates

Lead Judging Commences

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

finding-first-bridgeof-a-collection-L1<->L2-do-not-sync-addresses

Likelyhood: High, any collections bridged, without bridge owner action, will be unable to bridge back. Impact: High, L2 -> L1 tokens will be stuck in the bridge. L1 -> L2 will need to ask for a cancellation.

Support

FAQs

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