Founders can receive less tokens that expected
Founders' token IDs are computed incorrectly, so some IDs exceed 99 and are never minted, causing founders to receive fewer tokens than their percentage allocation. An attacker cannot directly exploit this, but founders lose expected tokens.
Submitted by MEP, also found by 141345, 0xSky, antonttc, azephiar, cccz, CertoraInc, d3e4, datapunk, davidbrai, easy_peasy, hansfriese, hansfriese, MiloTruck, minhtrng, neumo, pcarranzav, peritoflores, PwnPatrol, R2, scaraven, teawaterwire, Tointer, tonisives, unforgiven, V_B, wagmi, zkhorse, and zzzitron
Because the IDs of the founders tokens are wrongly computed, some of them can have an id higher than 100 and then never be minted.
Proof of Concept
If a founder has percentage of pct, then pct IDs between 0 and 99 should be given to him in the mapping tokenRecipient, such that if a token is minted with tokenId % 100 equal to one of its IDs, it is minted directly to him. But the modulo is not correctly done at when the mapping is filled, so some IDs of a founder can be higher than 100.
It happens for example if Alice has 10% and Bob gas 11%. For Alice, schedule is equal to 10, so Alices will have the ids 0, 10, 20, …, 90. But for Bob, schedule is also equal to 9. So it will have the ids 1, 11, 21, …, 91, 100. Indeed, Bob can’t have the ID 0 because it belongs to Alice, same for the ID 10 etc. The last eleventh ID that is given to Bob is 100, that can’t be reached.
This happens for example when with two founders the percentages verify (100 / pct1) - (100 / pct2) == 1. So (11%, 12%) or (25%, 33%) will behave samely (with more token lost in some case).
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { TokenTest } from "./Token.t.sol";
contract TestMEP_M1 is TokenTest {
function setUpMEP() internal returns (address alice, address bob, uint256 totalOwnership) {
address[] memory wallets = new address[](2);
uint256[] memory percents = new uint256[](2);
uint256[] memory vestExpiries = new uint256[](2);
wallets[0] = alice = address(0x0a);
wallets[1] = bob = address(0x0b);
percents[0] = 10;
percents[1] = 11;
totalOwnership = percents[0] + percents[1];
vestExpiries[0] = type(uint256).max;
vestExpiries[1] = type(uint256).max;
deployWithCustomFounders(wallets, percents, vestExpiries);
}
// Verifies it on the 100 first tokens
function testMEP_M1_1() public {
(address alice, address bob, uint256 totalOwnership) = setUpMEP();
// Should mint the 100 first tokens
// Alice should receive 10 tokens
// Bob should receive 11 tokens
for (uint256 i; i < 100 - totalOwnership; ++i) {
vm.prank(address(auction));
token.mint();
}
assertEq(token.balanceOf(alice), 10, "Alice's balance is wrong");
assertEq(token.balanceOf(bob), 11, "Bob's balance is wrong");
}
// Verifies it with the law of large numbers
function testMEP_M1_2() public {
(address alice, address bob, ) = setUpMEP();
uint256 tokensToMint = 123456; // enough large to apply the law of large numbers
for (uint256 i; i < tokensToMint; ++i) {
vm.prank(address(auction));
token.mint();
}
uint256 totalSupply = token.totalSupply();
assertEq(token.balanceOf(alice) * 100 / totalSupply, 10, "Alice's percentage is wrong");
assertEq(token.balanceOf(bob) * 100 / totalSupply, 11, "Bob's percentage is wrong");
}
}
Recommended Mitigation Steps
Replace the line 118 of Token.sol by baseTokenId = (baseTokenId + schedule) % 100;.
Alex the Entreprenerd (judge) commented:
The warden has shown how, due to a logical mistake / typo, founders will receive a lower allocation than expected.
This is contingent on certain allocations being set and will cause a “loss of yield” to the founders estimated to the lost allocation.
I believe the finding could be raised to High Severity due to the graveness of it, however, because it is contingent on specific inputs, I think Medium Severity to be appropriate
tbtstl (Nouns Builder) disagreed with severity and commented:
I actually think this one should be high severity – it’s important that these token ownership percentages end up consistent on a long enough time scale.
Alex the Entreprenerd (judge) commented:
I appreciate the generosity of the sponsor, ultimately the bug can happen only if
(baseTokenId + schedule)is greater than 100, which, because the schedule is X / 100, will not always happen, and the loss will not be total but only for the specific tokens for which the modulo is necessary.For those reasons (conditionality of bug due to admin input), I think Medium Severity to be more appropriate.
I do recommend mitigation nonetheless.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a missing modulo operation when calculating the next token ID for each founder, causing IDs to exceed 99.
Impact
Founders could receive fewer tokens than their specified percentage, with the loss depending on the exact percentages set.
What the attacker needed
Founders' percentages set such that (100/pct1) - (100/pct2)…; Token contract deployed with those founders
The fix
The modulo operation should be applied when calculating the base token ID, as in `baseTokenId = (baseTokenId + schedule) % 100;`.
How it was found
- Deploy the token contract with two founders having percentages 10% and 11%.
- Mint the first 100 tokens.
- Observe that Bob receives only 10 tokens instead of 11, because one of his assigned IDs is 100, which is never minted.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a project starts, founders are promised a percentage of tokens. The code assigns each founder specific token numbers (like 0, 10, 20) that will be minted directly to them. A mistake in the maths means some assigned numbers are above 99, which never get minted, so founders get less than promised.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.