Admin won't be able to remove collections from the whitelist on L2 in certain cases. The issue stems from the fact that there's a missing line in the _white_list_collection function in the bridge.cairo contract that will make the function loop indefinitely if the collection to be removed is after 2nd place in the linked list.
Removing a collection by an admin should always be possible. This will have an even bigger impact if a malicious collection finds its way into the whitelist either by accident or at a time that the whitelist has been off.
The white_list_collection() function is used by admins to add or remove collections from the whitelist. It utilizes the internal _white_list_collection(). Let's take a look at it:
Let's consider the following scenario:
We have a linked list structure of the following collections: A -> B -> C -> D and we want to remove C
let mut prev = self.white_listed_head.read(); sets prev to A.
Entering the else branch since enabled is false and we're removing a collection from the whitelist.
if prev == collection is false since A != C so we go to the loop
First Loop Iteration:
let (active, next) = self.white_listed_list.read(prev); reads B (next of A).
Since B is not zero and active, these ifs are skipped if next.is_zero(), !active, and the function proceeds.
Since next (B) is not the target collection (C), this returns false if next == collection and the if is skipped.
At this point, the loop should move to the next element, but the missing line prev = next; is not there.
The loop incorrectly processes B again in the next iteration.
This will continue indefinitely since no break condition will be met, causing the function to revert because of out-of-gas at some point and making the target collection impossible to remove.
Admins can't remove certain collections from the whitelist breaking the core functionality of the _white_list_collection function.
Manual review
Add the prev = next line at the spot I've pointed out in the code above.
Likelyhood: High, owner can only unwhitelist the 2 first collections. Impact: Medium/High, owner has to empty the list to remove any collection, and replace all the new ones.
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.