Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: low
Invalid

Unnecessary onlyOwner Modifier in Constructor Function

Summary

The constructor of the MartenitsaEvent.sol contract utilizes the onlyOwner modifier, which restricts its execution to the contract owner. However, this restriction appears unnecessary for a constructor function.

Vulnerability Details

The use of the onlyOwner modifier in the constructor function imposes an unnecessary constraint, as constructor functions are automatically executed by the deploying address, which is typically the contract owner. The onlyOwner modifier is commonly employed in functions that require privileged access control, but applying it to a constructor adds no additional security or functionality.

Impact

While this redundancy does not introduce a security vulnerability per se, it may contribute to code complexity and maintenance overhead. Unnecessary modifiers can obscure the intent of the code and increase the risk of errors during contract deployment or upgrades.

Tools Used

manual code review.

Recommendations

To streamline the contract and improve readability, it is advisable to remove the onlyOwner modifier from the constructor function. This action simplifies the codebase without compromising security or functionality.

Example:

constructor(address healthToken) {
_healthToken = HealthToken(healthToken);
}

By removing the unnecessary modifier, the constructor becomes more concise and aligns with common coding practices.

Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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