Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Valid

Minting Mechanism Exploit: Direct Battle Entry with High Skills

Summary

The mintRapper function in OneShot.sol improperly initialises OneShot::rapperStats before any gameplay, granting newly minted NFTs unearned skill advantages, which undermines the intended game mechanics.

Vulnerability Details

The default values of OneShot::rapperStats for a newly minted NFT are beneficial to the player (weakKnees: false, heavyArms: false, spaghettiSweater: false, calmAndReady: false, battlesWon: 0). Score +15 already.

A malicious player could take control when he receives a NFT with a custom implementation of onERC721Received. He will then reenter on RapBattle::goOnStageOrBattle.

Impact

It gives an unfair advantage to players who mint new NFTs. Nevertheless the game is also based on chance in the end.

Tools Used

Manual Review

Recommendations

Restructure the OneShot::mintRapper to follow the Checks-Effects-Interactions pattern strictly. Ensure all state changes are performed before any extenal interaction.

function mintRapper() public {
uint256 tokenId = _nextTokenId++;
- _safeMint(msg.sender, tokenId);
- rapperStats[tokenId] =
- RapperStats({weakKnees: true, heavyArms: true, spaghettiSweater: true, calmAndReady: false, battlesWon: 0});
+ rapperStats[tokenId] =
+ RapperStats({weakKnees: true, heavyArms: true, spaghettiSweater: true, calmAndReady: false, battlesWon: 0});
+ _safeMint(msg.sender, tokenId);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

mintRapper reentrancy leads to fighting having better chances of winning.

Support

FAQs

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

Give us feedback!