HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: high
Invalid

Missing Zero-Address Validation for Contract Owner in Constructor

Security Analysis Report

File: WToken.sol
Occurrence: Line 16


Summary

The constructor of the WToken contract does not validate the owner_ parameter, allowing it to be set to the zero address (address(0)). This oversight can result in the contract becoming non-functional as no valid owner would be able to execute onlyOwner functions.


Vulnerability Details

The absence of a require statement to validate the owner_ parameter in the constructor allows the _owner to be set as the zero address. The zero address is a special address in Ethereum that no one controls, which leads to the inaccessibility of all functions restricted to the onlyOwner modifier.

Code Snippet:

constructor(string memory symbol_, uint8 decimals_, address owner_) ERC20(symbol_, symbol_) {
_owner = owner_; // No validation for address(0)
_decimals = decimals_;
}

Impact

If the _owner is set to the zero address:

  • Owner-Only Functions Inaccessible: Functions such as mint and burn will no longer be executable, resulting in a denial of service for these operations.

  • Irrecoverable Contract State: The lack of a valid owner makes the contract irrecoverable without redeployment.

  • Operational and Financial Risks: If the contract is used in a larger system, its malfunction can disrupt dependent components, potentially leading to financial losses or governance deadlocks.

Severity: Medium to High (depends on how critical owner-only operations are for the system).


Tools Used

  • Manual code review

  • Static analysis of constructor parameters


Recommendations

To mitigate the issue, add a validation check in the constructor to ensure that the owner_ parameter is not the zero address. The updated constructor should look like this:

constructor(string memory symbol_, uint8 decimals_, address owner_) ERC20(symbol_, symbol_) {
require(owner_ != address(0), "WToken: owner cannot be the zero address");
_owner = owner_;
_decimals = decimals_;
}
Updates

Lead Judging Commences

bube Lead Judge 4 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.