DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing zero address validation in `LikeRegistry` constructor (Input Validation + Contract Initialization Risk)

Description: The LikeRegistry constructor accepts an address parameter _profileNFT but does not validate if it's a zero address. The address is used to initialize the critical profileNFT variable which is essential for the contract's core functionality.

constructor(address _profileNFT) Ownable(msg.sender) {
profileNFT = SoulboundProfileNFT(_profileNFT); // No zero-address check
}

Impact:

  • If deployed with address(0), the contract would need to be redeployed

  • All functions that interact with profileNFT would fail

  • Could lead to unnecessary gas costs from failed deployment

Proof of Concept:

// This deployment would succeed but make the contract unusable
LikeRegistry registry = new LikeRegistry(address(0));
// All these functions would fail when trying to use profileNFT
registry.likeUser(); // reverts
registry.matchRewards(); // reverts

Recommended Mitigation: Add a zero address check in the constructor:

+ error LikeRegistry__ZeroProfileNFTAddress();
constructor(address _profileNFT) Ownable(msg.sender) {
+ if(_profileNFT == address(0)) {
+ revert LikeRegistry__ZeroProfileNFTAddress();
+ }
profileNFT = SoulboundProfileNFT(_profileNFT);
}
Updates

Appeal created

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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