Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

Contract Functionality Locked Behind Uninitialised gameContract

Summary

The EggstravaganzaNFT contract's functionality is contingent on proper initialisation of the gameContract address via setGameContract. If the owner fails to execute this function, the protocol becomes permanently non-functional as the mintEgg method remains inaccessible. While not directly exploitable, this represents a critical deployment failure vector.

Vulnerability Details

Affected Code:

function mintEgg(address to, uint256 tokenId) external returns (bool) {
require(msg.sender == gameContract, "Unauthorized minter"); // gameContract = address(0) by default
_mint(to, tokenId);
totalSupply += 1;
return true;
}

Technical Analysis:

  1. Uninitialised State Risk:

    • The gameContract state variable defaults to address(0)

    • The setGameContract function is the only way to configure this critical parameter

    • No initialisation occurs in the constructor

  2. Protocol Bricking Scenario:

    • If owner neglects to call setGameContract after deployment

    • mintEgg becomes permanently unreachable

    • Entire game functionality is paralysed as no NFTs can be minted

  3. Key Constraints:

    • Represents a single point of failure in protocol initialisation

Impact

Severity: High

  • Protocol-Wide Failure: Renders core game mechanics permanently inoperable

  • Irreversible Damage: Requires contract redeployment if initialisation is missed

Likelihood: Medium

  • Depends on human operational processes during deployment

  • Common in rushed deployments without proper verification

Tools Used

Manual code analysis of initialisation flows

Recommendations

  1. Constructor Initialisation:

// Updated constructor
constructor(string memory _name, string memory _symbol, address _initialGameContract)
ERC721(_name, _symbol) Ownable(msg.sender)
{
require(_initialGameContract != address(0), "Invalid game contract");
gameContract = _initialGameContract;
}

Remove Owner Dependency:

  • Delete the setGameContract function entirely to prevent post-deployment misconfiguration

Updates

Lead Judging Commences

m3dython Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Trusted Owner

Owner is trusted and is not expected to interact in ways that would compromise security

Support

FAQs

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