withdraw_auto_from_l1
function in bridge.cairo does not check whether previously deployed collection on L2 is still whitelisted.
This means a transaction can go through to a collection which has been removed from the whitelist.
https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/starknet/src/bridge.cairo#L141
withdraw_auto_from_l1
gets the address of collection_l2 from the function ensure_erc721_deployment
https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/starknet/src/bridge.cairo#L428
- The function ensure_erc721_deployment
deploys a new collection, if it is not already deployed, and whitelists it. But for an existing collection the address is simply returned ref https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/starknet/src/bridge.cairo#L440
The main withdraw_auto_from_l1
function does not then check whether this address is still whitelisted.
The following test shows how an NFT could be transferred from L1 to a collection which was not whitelisted.
Running snforge test withdraw_token_with_mapping
for the test above - shows the test passes and confirms the finding.
The impact can be high if, for example, a collection was removed from the whitelist because it was compromised. The withdraw_auto_from_l1
will then interact with a compromised contract through the transfer_from
function which can cause arbitrary damage/loss of NFT for the user.
Manual review and snforge test
Having a simple check assert(_is_white_listed(@self, collection_l2), 'Collection not whitelisted');
after getting the collection_l2
address from ensure_erc721_deployment
function would ensure that transfer cannot be made to a non-whitelisted collection. This will revert the transaction and message from L1 would remain unconsumed. The user would then need to cancel the transaction on L1 side to recover the NFT from escrow.
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.