NFTBridge
60,000 USDC
View results
Submission Details
Severity: medium
Invalid

Potential Exploit in `verify_collection_address` Function Due to Misplaced `l1_req` and `l1_bridge` Checks

Summary

The verify_collection_address function in collection-manager.cairo checks the l1_req and l1_bridge parameters later in the function, which can be exploited to override collection addresses under specific conditions.

Vulnerability Details

The l1_req and l1_bridge checks occur after other conditions are evaluated. If l2_req and l2_bridge are both zero, but l1_req and l1_bridge differ, the function can incorrectly return a zeroed contract address without verifying the L1 addresses, allowing an attacker to override the collection address.

Impact

This vulnerability could allow an attacker to manipulate the collection addresses, potentially leading to unauthorized control or mismanagement of collections, which could have severe consequences in a production environment.

Recommendations

Move the l1_req and l1_bridge checks to the beginning of the function to ensure that these critical validations occur before any other logic is executed. This will prevent the possibility of exploiting the function to override collection addresses.

fn verify_collection_address(
l1_req: EthAddress,
l2_req: ContractAddress,
l1_bridge: EthAddress,
l2_bridge: ContractAddress,
) -> ContractAddress {
// Validate L1 and L2 addresses upfront
if l1_req != l1_bridge {
panic!("Invalid collection L1 address");
}
if !l2_req.is_zero() && l2_bridge != l2_req {
panic!("Invalid collection L2 address");
}
// Original logic follows here...
}

This adjustment secures the function against the potential exploit and ensures that all critical checks are performed early.

Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.