Eggstravaganza

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

Unrestricted owner control over game mechanics enables unfair gameplay manipulation

Summary

The EggHuntGame::setEggFindThreshold function allows the contract owner to arbitrarily change the egg-finding probability without restrictions or transparency, creating a centralization risk that undermines game fairness.

Vulnerability Details

The owner can set the egg-finding threshold to any value between 0-100% at any time:

## EggHuntGame.sol
function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= 100, "Threshold must be <= 100");
eggFindThreshold = newThreshold;
}

This function:

  1. Has no cooldown between changes

  2. Has no limits on how drastically the threshold can change

  3. Emits no events to notify players of changes

  4. Can be called even during active gameplay

Impact

  • Owner can silently manipulate game outcomes to favor specific players

  • Players have no visibility into threshold changes

  • Game fairness is entirely dependent on owner's trustworthiness

  • Potential for abuse if there are economic incentives tied to egg collection

Tools Used

  • Manual code review

Recommendations

Implement constraints on the owner's ability to manipulate game mechanics:

+ uint256 public lastThresholdUpdateTime;
+ uint256 public constant THRESHOLD_CHANGE_COOLDOWN = 1 days;
+ uint256 public constant MAX_THRESHOLD_CHANGE = 10;
+ event EggFindThresholdChanged(uint256 oldValue, uint256 newValue);
function setEggFindThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= 100, "Threshold must be <= 100");
+ require(block.timestamp >= lastThresholdUpdateTime + THRESHOLD_CHANGE_COOLDOWN, "Too soon to change");
+ require(newThreshold <= eggFindThreshold + MAX_THRESHOLD_CHANGE &&
+ newThreshold >= eggFindThreshold - MAX_THRESHOLD_CHANGE,
+ "Change too large");
+ uint256 oldThreshold = eggFindThreshold;
eggFindThreshold = newThreshold;
+ lastThresholdUpdateTime = block.timestamp;
+ emit EggFindThresholdChanged(oldThreshold, newThreshold);
}
Updates

Lead Judging Commences

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

Give us feedback!