code-423n4 / 2022-09-nouns-builder-findings

10 stars 6 forks source link

Upgraded Q -> M from 424 [1664289758524] #733

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Judge has assessed an item in Issue #424 as Medium risk. The relevant finding follows:

GalloDaSballo commented 2 years ago

Reserved tokens IDS are calculated wrong Reserved token ids are calculated in a weird way in token._addFounders() at this line of code at Token.sol#L113:

(baseTokenId += schedule) % 100 What this is actually doing is:

baseTokenId = baseTokenId + (schedule % 100); Impact Due to a combination of this and schedule being calculated as:

uint256 schedule = 100 / founderPct; which rounds down to 1 for founderPct >= 51 it causes the remaining founders to get less tokens.

Intuitevely what should happen is that baseTokenId might result in values higher than 99. This can happen if one founderPct is 2 because that sets schedule to 50.

Unfortunately I discovered this quite late in the contest and didn't have time to indagate further. What seems weird to me is that the code seems to work anyway for most the of the cases.

Changing:

(baseTokenId += schedule) % 100 to

baseTokenId = (baseTokenId + schedule) % 100 seems to fix the issue even for cases in which 1 founder has more than 51 ownershipPcts.

Dup of #269