Eggstravaganza

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

The 'game started' flag is not being checked in the deposit function.

Summary

You're not checking whether the game has started when depositing the NFT into the user's vault.

Vulnerability Details

function depositEggToVault(uint256 tokenId) external {
require(eggNFT.ownerOf(tokenId) == msg.sender, "Not owner of this egg");
// you need to check the game has been started or not
// require(block.timestamp >= startTime, "Game not started yet");
eggNFT.transferFrom(msg.sender, address(eggVault), tokenId);
eggVault.depositEgg(tokenId, msg.sender);
}

require(block.timestamp >= startTime, "Game not started yet"); is missing. Users should not be allowed to deposit NFTs into the vault before the game starts.

Impact

The user hasn't minted any NFTs before the game starts, so there's no point in allowing NFT deposits before the game begins.

Tools Used

vs code

Recommendations

add require(block.timestamp >= startTime, "Game not started yet"); In code.

function depositEggToVault(uint256 tokenId) external {
require(eggNFT.ownerOf(tokenId) == msg.sender, "Not owner of this egg");
require(block.timestamp >= startTime, "Game not started yet");
// The player must first approve the transfer on the NFT contract.
eggNFT.transferFrom(msg.sender, address(eggVault), tokenId);
eggVault.depositEgg(tokenId, msg.sender);
}
Updates

Lead Judging Commences

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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