NFT Dealers

First Flight #58
Beginner FriendlyFoundry
100 EXP
Submission Details
Impact: low
Likelihood: high

Redundant Zero-Address Check on `msg.sender`

Author Revealed upon completion

Root + Impact

Description

  • Normal Behavior: Input validation is used to prevent errors or security breaches caused by invalid addresses (like address(0)). Usually, this is applied to addresses passed as arguments by the user.


  • Specific Issue: The mintNft function checks if msg.sender is address(0). In Solidity, msg.sender is globally defined by the EVM as the caller of the contract. Since a transaction must be signed by a valid account, msg.sender can never be the zero address.

function mintNft() external payable onlyWhenRevealed onlyWhitelisted {
@> if (msg.sender == address(0)) revert InvalidAddress();
// ...
}

Risk

Likelihood: High

  • This redundant check is executed every single time a user mints an NFT.

Impact: Low (Gas)

  • Impact 1: Wasted Gas. The contract performs a comparison operation and a conditional jump that can never be triggered. This costs roughly 20-50 gas per mint.

  • Impact 2: Code Clutter. Including impossible checks makes the codebase less professional and slightly harder to read for other auditors or developers.

Proof of Concept

Recommended Mitigation

Remove the redundant check.

Support

FAQs

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

Give us feedback!