Trail of Bits: https://github.com/crytic/building-secure-contracts/tree/master/not-so-smart-contracts/cairo/L1_to_L2_address_conversionThe vulnerability arises from a missing validation check in the setL1L2CollectionMapping function.
Specifically, there is no verification to ensure that collectionL2 is less than P (felt252)
Although it is the owner's responsibility to set the correct mapping, the absence of a validation check creates a critical risk.
if owner sets an incorrect collectionL2 there is no opportunity for correction, and the funds could be irretrievably lost.
P = 2^251 + 17 * 2^192 + 1 -> 3618502788666131213697322783095070105623107215331596699973092056135872020481
The vulnerability is centered on the lack of a validation step in the setL1L2CollectionMapping function.
The collectionL2 variable is not checked against P, a crucial upper bound that should be enforced. If collectionL2 exceeds P
it can cause an overflow, which will not revert the transaction. This issue becomes particularly critical if an incorrect collectionL2
value is set in the same block where a user calls depositTokens. Since both actions occur in the same block,
there is no window for the owner to correct the mistake before the user's assets are at risk.
The problem is exacerbated by the fact that the admin is a person who might manually perform these operations,
increasing the likelihood of human error.
The absence of a check on collectionL2 can result in an overflow, causing assets to be sent to an invalid address or lost.
Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.
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.