Eggstravaganza

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

`Owner` of `EggstravaganzaNFT` is able to change the game contract at any time

Summary

The Owner is able to change the game contract with EggstravaganzaNFT::setGameContract at any time, leading to possible breach of trust or breaking the NFT minting.

Vulnerability Details

The Owner of the EggstravaganzaNFT contract is able to call EggstravaganzaNFT::setGameContract at any time, regardless of the state of the EggHuntGame contract. This allows the Owner to break the game protocol, specifically the EggHuntGame::searchForEgg function.

The EggHuntGame::searchForEgg function makes a call to EggstravaganzaNFT::mintEgg whenever a Player finds an egg. However, if the Owner of the EggstravaganzaNFT contract changes the game contract via EggstravaganzaNFT::setGameContract, the call will revert on require(msg.sender == gameContract, "Unauthorized minter");, preventing any Players from being able to be minted the NFT.

Impact

Breaks the protocol, Players unable to mint found eggs.

Tools Used

Manual review.

Recommendations

A possible solution may be to add an additional function that disables the ``EggstravaganzaNFT::setGameContract` function once set:

bool setGameContractEnabled = true;
function disableSetGameContract() external onlyOwner {
setGameContractEnabled = false;
}
function setGameContract(address _gameContract) external onlyOwner {
require(setGameContractEnabled == true, "Game contract already set");
require(_gameContract != address(0), "Invalid game contract address");
gameContract = _gameContract;
setGameContractEnabled = false;
}
Updates

Lead Judging Commences

m3dython Lead Judge 7 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.