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
function _getNextTokenId(uint256_tokenId) internalviewreturns (uint256) {
unchecked {
while (tokenRecipient[_tokenId].wallet !=address(0)) {
_tokenId = (++_tokenId) %100;
}
return _tokenId;
}
}
Initially, baseTokenId is the same as reservedUntilTokenId, if its founder info is not set, then the same value will be used as key to map founder info:
tokenRecipient[baseTokenId] = newFounder;
When mints a token, baseTokenId is calculated as below:
uint256 baseTokenId = _tokenId %100;
If tokenRecipient[baseTokenId].wallet points to founder's wallet, then the token will be set to the founder.
reservedUntilTokenId is 100, then baseTokenId is 100
tokenRecipient[_tokenId].wallet is address(0), then tokenRecipient[100] is set to founder info
When mints a token, because baseTokenId = _tokenId % 100, it will never be 100, so tokenRecipient[100] can never be matched, the founder info is thus never be get, no token will be sent to founder.
sherlock-admin2
changed the title
Large Ruby Sidewinder - tokenRecipient mapping maps invalid baseTokenId to founder info
circlelooper - tokenRecipient mapping maps invalid baseTokenId to founder info
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
circlelooper
high
tokenRecipient mapping maps invalid baseTokenId to founder info
Summary
tokenRecipient mapping maps invalid
baseTokenId
tofounder
info.Vulnerability Detail
tokenRecipient mapping maps
baseTokenId
tofounder
info.When Token contract is initialized,
founder
info is added totokenRecipient
by calling _addFounders().baseTokenId is set as key to
founder
info, and it is returned by _getNextTokenId():Initially,
baseTokenId
is the same asreservedUntilTokenId
, if itsfounder
info is not set, then the same value will be used as key to mapfounder
info:tokenRecipient[baseTokenId] = newFounder;
When mints a token,
baseTokenId
is calculated as below:If
tokenRecipient[baseTokenId].wallet
points tofounder
's wallet, then the token will be set to thefounder
._mint(tokenRecipient[baseTokenId].wallet, _tokenId);
Consider the following scenario:
reservedUntilTokenId
is 100, thenbaseTokenId
is 100tokenRecipient[_tokenId].wallet
isaddress(0)
, thentokenRecipient[100]
is set tofounder
infobaseTokenId = _tokenId % 100
, it will never be 100, sotokenRecipient[100]
can never be matched, thefounder
info is thus never be get, no token will be sent to founder.Impact
No token will be sent to founder.
Code Snippet
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L265
Tool used
Manual Review
Recommendation
Please consider to set
baseTokenId
to be less than 100 while calculating:Duplicate of #42
The text was updated successfully, but these errors were encountered: