You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
sherlock-admin opened this issue
Dec 1, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
First founder will get less tokens due to wrong calculation of first base token id
Summary
Incorrect first base token id will cause first founder user to receive less tokens
Vulnerability Detail
In function _addFounders, for a given precentage of token share, base token ids are calculated and assigned to the founders
But the calculation starts with reserveUntilTokenId, whose value may be > 99, and is assigned directly to the first founder as baseTokenId
uint256 baseTokenId = reservedUntilTokenId;
So during minting, the first founder will receive a percentage less tokens
This value will be retained in the tokenRecipient mapping and wont be cleared during updateFounders
Impact
First founder will receive less tokens due to the wrong calculation of first baseId
function _addFounders(IManager.FounderParams[] calldata_founders, uint256reservedUntilTokenId) internal {
...
uint256 baseTokenId = reservedUntilTokenId;
// For each token to vest:for (uint256 j; j < founderPct; ++j) {
// Get the available token id
baseTokenId =_getNextTokenId(baseTokenId);
// Store the founder as the recipient
tokenRecipient[baseTokenId] = newFounder;
emitMintScheduled(baseTokenId, founderId, newFounder);
// Update the base token id
baseTokenId = (baseTokenId + schedule) %100;
}
}
// Store the founders' details
settings.totalOwnership =uint8(totalOwnership);
settings.numFounders = numFoundersAdded;
}
}
/// @dev Finds the next available base token id for a founder/// @param _tokenId The ERC-721 token idfunction _getNextTokenId(uint256_tokenId) internalviewreturns (uint256) {
unchecked {
while (tokenRecipient[_tokenId].wallet !=address(0)) {
_tokenId = (++_tokenId) %100;
}
return _tokenId;
}
}
function _isForFounder(uint256_tokenId) privatereturns (bool) {
// Get the base token iduint256 baseTokenId = _tokenId %100;
// If there is no scheduled recipient:if (tokenRecipient[baseTokenId].wallet ==address(0)) {
returnfalse;
// Else if the founder is still vesting:
} elseif (block.timestamp< tokenRecipient[baseTokenId].vestExpiry) {
// Mint the token to the founder_mint(tokenRecipient[baseTokenId].wallet, _tokenId);
returntrue;
// Else the founder has finished vesting:
} else {
// Remove them from future lookupsdelete tokenRecipient[baseTokenId];
returnfalse;
}
}
sherlock-admin2
changed the title
Lucky Clear Dragonfly - First founder will get less tokens due to wrong calculation of first base token id
saian - First founder will get less tokens due to wrong calculation of first base token id
Dec 13, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
saian
medium
First founder will get less tokens due to wrong calculation of first base token id
Summary
Incorrect first base token id will cause first founder user to receive less tokens
Vulnerability Detail
In function
_addFounders
, for a given precentage of token share, base token ids are calculated and assigned to the foundersBut the calculation starts with reserveUntilTokenId, whose value may be > 99, and is assigned directly to the first founder as baseTokenId
So during minting, the first founder will receive a percentage less tokens
This value will be retained in the tokenRecipient mapping and wont be cleared during
updateFounders
Impact
First founder will receive less tokens due to the wrong calculation of first baseId
Code Snippet
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L120
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L263
Tool used
Manual Review
Recommendation
Change the first base token id to
or
Duplicate of #42
The text was updated successfully, but these errors were encountered: