An attacker can exploit the lack of collection removal mechanism to indefinitely increase the _collections
array size, leading to out-of-gas errors and denial of service when calling withdrawTokens
when a fresh new L1 collection is created.
The root cause is an unbounded growth of the _collections
array used for whitelist checks. As new collections are added over time, the gas cost of iterating through this array in the _isWhiteListed
function increases linearly.
Eventually, this leads to out-of-gas errors when attempting to execute the withdrawTokens
function, rendering it unusable.
Futhermore, the vulnerability is high as there's no mechanism to remove collections element from the _collections
array.
The vulnerability will be explained for the ETH side as the impact is greater.
The attacker initiates multiple withdrawals from L2 to L1 with new arbitrary L2 collections when white_list_enabled
is false (which is the default state).
Each withdrawal creates a new collection on L1, increasing the _collections
array.
As there's no mechanism to remove collection item from _collections
array, the functions getWhiteListedCollections
and _whiteListCollection
which are called by withdrawTokens
will be DOS as it iterates over the whole unlimited size array.
The withdrawTokens
function becomes inoperable due to excessive gas consumption. This critically impairs a core feature of the Ark Project: the ability to dynamically create a collection on the L1 side to mint bridged NFTs from Starknet when no collection mapping exists. The gas-intensive operation of iterating through an ever-growing list of collections in the whitelist check causes transactions to fail, effectively breaking the bridge's L2 to L1 transfer capability.
Manual review
Implement a gas-efficient data structure for whitelist checks:
Consider using a mapping for O(1) lookup instead of array iteration
Explore Merkle tree validation for whitelist proofs
Bounded collection list:
Introduce a mechanism to remove unused or outdated collections from _collections
Implement a maximum size limit for the _collections
array
Likelyhood: High, once the whitelist option is disabled, collections will grow. Impact: High, withdraw won’t be possible because of Out-Of-Gas.
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.