The functions in both GivingThanks.sol
and CharityRegistry.sol
lack checks to prevent the use of address(0)
. This can lead to critical issues, such as accidentally setting important addresses to address(0)
or sending Ether to the zero address. It is a best practice to ensure that addresses passed to functions are not address(0)
.
Missing Zero Address Check:
The functions such as updateRegistry
, donate
, changeAdmin
, and verifyCharity
do not verify if the passed address is address(0)
. Using address(0)
could cause unexpected behaviors, such as sending Ether to an invalid address or making an address such as the admin address invalid (address(0)
).
address(0)
could allow for critical issues:If address(0)
is used for the admin
address in CharityRegistry.sol
, this would break the ability to perform administrative actions.
If address(0)
is passed as the charity address in donate
, the contract would attempt to send Ether to the zero address, effectively losing the Ether.
The same applies to setting the registry address or charity verification, leading to loss of functionality.
Manual Code Review
Create a Modifier to Check for Zero Address:
Implement a nonZeroAddress
modifier to check if the provided address is address(0)
before executing the function logic.
Apply the Modifier to Critical Functions:
The nonZeroAddress
modifier should be applied to all functions that involve updating addresses, such as updateRegistry
, donate
, changeAdmin
, and any other relevant functions that deal with addresses.
Update Constructors and Functions:
Apply the check in the constructor to ensure the provided addresses are not address(0)
during initialization.
Create the nonZeroAddress
Modifier:
** Apply the Modifier to Functions:**
GivingThanks.sol
:CharityRegistry.sol
: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.