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

The `OneShot::mintRapper` function does not adhere to the CEI (Checks-Effects-Interactions) pattern.

Description: The mintRapper function updates contract state after calling the safeMint function, potentially exposing the function to a reentrancy attack.

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

Impact: The impact of this vulnerability is currently low due to the absence of any funds at risk in this specific function. However, it can introduce unpredictability and potential security risks.

Recommended Mitigation: Refactor the OneShot::mintRapper to follow the CEI pattern, placing the state change before the external call for security and predictability.

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

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year 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.