GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Missing Zero Address Validation in `CharityRegistry.sol`

Description: The contract lacks zero address validation in critical functions such as CharityRegistry::changeAdmin() and CharityRegistry::registerCharity() where addresses are used as parameters. This could lead to irrecoverable states if zero addresses are accidentally input.

function changeAdmin(address newAdmin) public
function registerCharity(address charity) public

Impact:

  • Admin role could be permanently lost if set to zero address

  • Charities could be registered with zero address

  • No way to recover from these states due to lack of validation

Proof of Concept:

function testZeroAddressVulnerability() public {
vm.prank(admin);
registry.changeAdmin(address(0));
// Contract now has zero address admin
assertEq(registry.admin(), address(0));
}

Recommended Mitigation: Add zero address validation checks such as given below:

modifier nonZeroAddress(address _address) {
require(_address != address(0), "Zero address not allowed");
_;
}
function changeAdmin(address newAdmin) public onlyAdmin nonZeroAddress(newAdmin) {
admin = newAdmin;
emit AdminChanged(newAdmin);
}
Updates

Lead Judging Commences

n0kto Lead Judge 12 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.