Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Phantasmagoria - Wrong check in mintPlayers() function allows mint more players #312

Closed
sherlock-admin opened this issue May 5, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented May 5, 2023

Phantasmagoria

medium

Wrong check in mintPlayers() function allows mint more players

Summary

Wrong check in mintPlayers() function allows mint more players

Vulnerability Detail

From the documentation, we can see that users should be able to mint 10 players.

maxGenerationId: The maximum integer generationId that can be used to mint
players. This is the number of players that can be minted per cohort. At game
launch this value will be 10.

However, the following check is incorrect, as it always allows minting 11 players instead of the intended 10.

if (generationId > _maxGenerationId) {
        revert GenerationIDTooHigh(generationId, _maxGenerationId);
}

generationIds is an array. Loop begin counting from 0

uint256 generationId;
for (uint256 i = 0; i < generationIds.length; ) {

Because of the first index in an array is zero the check will only revert when generationId is 11 allowing users to mint more players

Impact

User can mint more players than he should be

Code Snippet

if (generationId > _maxGenerationId) {
        revert GenerationIDTooHigh(generationId, _maxGenerationId);
}

https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumAcademy.sol#L186-L188

Tool used

Manual Review

Recommendation

Change generationId > _maxGenerationId to generationId >= _maxGenerationId

Duplicate of #152

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 10, 2023
@sherlock-admin sherlock-admin added Medium A valid Medium severity issue Reward A payout will be made for this issue and removed High A valid High severity issue labels May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant