Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Duplicate Ownership Transfer Functions in Contract

01. Relevant GitHub Links

02. Summary

The contract defines two functions with identical functionality for transferring ownership: transferOwnership and changeOwner. This redundancy could cause confusion, leading to unintended calls or misuse, as both functions provide the same result but are implemented separately.

03. Vulnerability Details

The contract already has a public transferOwnership function for ownership transfer, but an additional changeOwner function is implemented, which simply calls transferOwnership with the same parameters. This creates duplicated functionality in the contract, which not only increases gas costs but also risks confusion or mistakes among users or developers.

function changeOwner(address _newOwner) public {
transferOwnership(_newOwner);
}

Having multiple public functions with the same purpose can reduce clarity and may inadvertently lead to unexpected behavior, especially if permissions or access control are changed in the future.

03. Impact

  • Increased Gas Costs: The redundant function call leads to unnecessary gas usage.

  • Increased Complexity: Having multiple functions with the same functionality can confuse users and developers, increasing the likelihood of errors.

  • Potential for Misuse: If access control is modified, having multiple entry points for the same action can lead to unexpected or unauthorized changes in ownership.

04. Proof of Concept

05. Tools Used

Manual Code Review and Foundry

06. Recommended Mitigation

  1. Remove the Redundant Function: Eliminate the changeOwner function to avoid confusion and maintain a single entry point for ownership transfer.`

  2. Document Ownership Transfer Method: If there’s a specific reason for an additional function, consider providing detailed documentation to clarify its usage and avoid confusion.

Updates

Appeal created

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