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

mstpr-brainbot - Clubs can mint +1 players more than maxGenerationId #152

Open
sherlock-admin opened this issue May 5, 2023 · 9 comments
Labels
Disagree With Severity The sponsor disputed the severity of this issue Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

mstpr-brainbot

high

Clubs can mint +1 players more than maxGenerationId

Summary

As stated in doc here
image
Initially clubs should be able to mint 10 players. However, clubs can always mint +1 players more than maxGenerationId

Vulnerability Detail

An off-by-one error is existed in academy contract when checking the generation ID while minting players. The code currently allows clubs to mint up to maxGenerationId + 1 players, which is inconsistent with the documentation. If clubs send generation IDs in the following sequence: 0-1-2-3-4-5-6-7-8-9-10, all of these numbers will be valid, and the club will be able to mint maxGenerationId + 1 players instead of the intended maxGenerationId

Impact

Since this is not intended behaviour according to the protocol docs, I'll label it as high.

Code Snippet

https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumAcademy.sol#L186-L188
here code checks whether the generation id is higher than maxGeneration or not, and it can be equal to maxGeneration.

Tool used

Manual Review

Recommendation

Use generationId >= _maxGenerationId or do not count the "0" index

@logiclogue
Copy link

Marked as 'Will Fix'. I believe the solution here is instead to update the documentation to say "At game launch this value will be 9". Because the documentation as far as I'm aware is correct in that it says maxGenerationId is the maximum generation ID, it's just that it does not represent the total players per cohort, which was the assumption with the default value being 10.

@logiclogue logiclogue added Sponsor Confirmed The sponsor acknowledged this issue is valid Disagree With Severity The sponsor disputed the severity of this issue and removed Sponsor Confirmed The sponsor acknowledged this issue is valid labels May 16, 2023
@ctf-sec ctf-sec added Medium A valid Medium severity issue and removed High A valid High severity issue labels May 19, 2023
@dugdaniels
Copy link

dugdaniels commented May 22, 2023

Escalate for 10 USDC

This should be considered Low/Informational.

The variable is named maxGenerationId. As the name implies (and as noted in the docs), it is the maximum integer ID that can be used to mint. A maxGenerationID of 10 therefore means that you can mint a player with an ID of 10. The sponsor confirmed that this is working as intended and that only the documentation needs to be clarified.

Furthermore, to imply that a maxGenerationId of 10 should actually enforce a max id of 9 is illogical.

Ultimately, it's a configuration variable and the sponsor is updating the documentation to reflect the value that will be set to at launch. A documentation update should only be considered as informational. There is no exploit here.

@sherlock-admin
Copy link
Contributor Author

sherlock-admin commented May 22, 2023

Escalate for 10 USDC

This should be considered Low/Informational.

The variable is named maxGenerationId. As the name implies (and as noted in the docs), it is the maximum integer ID that can be used to mint. A maxGenerationID of 10 therefore means that you can mint a player with an ID of 10. The sponsor confirmed that this is working as intended and that only the documentation needs to be clarified.

Furthermore, to imply that a maxGenerationId of 10 should actually enforce a max id of 9 is illogical.

Ultimately, it's a configuration variable and the sponsor is updating the documentation to reflect the value that will be set to at launch. A documentation update should only be considered as informational. There is no exploit here.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label May 22, 2023
@NishithPat
Copy link

Escalate for 10 USDC
Disagree with the sponsor's comment saying that the documentation is right and that maxGenerationId is "the maximum generation ID, it's just that it does not represent the total players per cohort" or "it is the maximum integer ID that can be used to mint".

The docs say that maxGenerationId is "the number of players that can be minted per cohort". Check the definition of maxGenerationId in the doc.

Then going by the docs, if maxGenerationId is the number of players that can be minted per cohort, then the contract does indeed allow maxGenerationId + 1 player to be minted. In that case, the issue should be valid.

@sherlock-admin
Copy link
Contributor Author

Escalate for 10 USDC
Disagree with the sponsor's comment saying that the documentation is right and that maxGenerationId is "the maximum generation ID, it's just that it does not represent the total players per cohort" or "it is the maximum integer ID that can be used to mint".

The docs say that maxGenerationId is "the number of players that can be minted per cohort". Check the definition of maxGenerationId in the doc.

Then going by the docs, if maxGenerationId is the number of players that can be minted per cohort, then the contract does indeed allow maxGenerationId + 1 player to be minted. In that case, the issue should be valid.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@logiclogue
Copy link

Sponsor here, agreed with @NishithPat . My original statement is incorrect, the documentation should be updated to remove the statement "the number of players that can be minted per cohort". Their suggestion is correct

@ctf-sec
Copy link
Collaborator

ctf-sec commented May 23, 2023

Based on the comments above, NishithPat escalation is valid

@hrishibhat
Copy link

Escalation accepted

Valid medium
Accepting @NishithPat's escalation
Given that the issue correctly identifies the flaw in the code as against what the documentation says it's supposed to do, this is a valid issue.

@sherlock-admin sherlock-admin added Escalation Resolved This issue's escalations have been approved/rejected and removed Escalated This issue contains a pending escalation labels Jun 2, 2023
@sherlock-admin
Copy link
Contributor Author

Escalation accepted

Valid medium
Accepting @NishithPat's escalation
Given that the issue correctly identifies the flaw in the code as against what the documentation says it's supposed to do, this is a valid issue.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Disagree With Severity The sponsor disputed the severity of this issue Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

6 participants