The setL1L2CollectionMapping
function in the Starklane contract does not perform any validation on the collectionL1
and collectionL2
addresses before setting the mapping. This lack of validation allow an attacker or a user to set arbitrary or invalid addresses as mappings, potentially leading to unexpected or insecure behavior in the contract.
Coped POC
The test results indicate that the setL1L2CollectionMapping
function allows the setting of arbitrary or invalid L1 and L2 addresses without any validation. Below is a breakdown of the relevant evidence from the test execution:
1: Setting an Invalid L1 Collection:
L1 Collection: 0x0000000000000000000000000000000000001234
L2 Collection: 103929005307130220006098923584552504982110632080
Active: false
Event Emitted: L1L2CollectionMappingUpdated
was emitted, indicating that the mapping was set despite the invalid nature of the collectionL1
address.
2: Setting a Valid L1 Collection with Arbitrary L2 Address:
L1 Collection: ERC721Bridgeable
L2 Collection: 870405419566846112171829716905735280232177611280
Active: false
Event Emitted: L1L2CollectionMappingUpdated
was emitted without validating the correctness of the L2
address.
3: Setting a Valid L1 Collection with Another Arbitrary L2 Address:
L1 Collection: ERC721Bridgeable
L2 Collection: 980829894800078742339098726298021775428853559041
Active: true
Event Emitted: L1L2CollectionMappingUpdated
was emitted again, confirming the lack of validation.
1: Invalid mappings could break functionality during operations that rely on the correctness of these mappings, such as token withdrawals or transfers.
2: An attacker could exploit this vulnerability to create mappings that could lead to unauthorized access or manipulation of tokens or other critical operations within the contract.
3: Mappings to non-existent or incorrect addresses could cause disruptions in the operation of the contract, potentially leading to loss of funds or other critical errors.
Manaul review
1: Introduce validation checks within the setL1L2CollectionMapping
function to ensure that the collectionL1
and collectionL2
addresses are valid, correctly formatted, and point to actual contracts or addresses that meet specific criteria.
2: Use require()
statements to enforce the validity of the addresses. This would prevent the function from proceeding if the provided addresses do not meet the necessary conditions.
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.