-
Notifications
You must be signed in to change notification settings - Fork 5
bin2chen - when reservedUntilTokenId > 100 first funder loss 1% NFT #42
Comments
Token.sol#_updateFounders
does not respect reservedUntilTokenId
.
#215
I initially separated the 4 findings below, but I agree, #177, #247 and #67 are only possible because of the following lines of code here, wherein uint256 baseTokenId = reservedUntilTokenId;
However, in the context of the audit period, I could also see why watsons separated these issues, so happy to hear from watsons during escalation period revolving deduplication of these issues. |
Fixed here: ourzora/nouns-protocol#122 |
Hi @neokry would be helpful if you could highlight to watsons here why you think the following primary issues should be duplicated under this issue: From my understanding it stems from the uint256 baseTokenId = reservedUntilTokenId; But it would be extremely helpful if you could provide a more detailed explanation in each finding, and show how the fix to #42 also fixes the rest of the findings. To all watsons, this is my initial deduplication here, feel free to also provide me the flow state of the functions to prove that they do not have the same root cause. |
Hi watsons, #67 and its duplicates Both #177 and #247 and its duplicates Unless a watson can prove to me that the fix implemented here by the sponsor is insufficient, I am inclined to keep all of them as duplicates except the above mentioned #67 and its duplicates. |
Fix looks good. BaseTokenId now always starts at 0. |
bin2chen
high
when reservedUntilTokenId > 100 first funder loss 1% NFT
Summary
The incorrect use of
baseTokenId = reservedUntilTokenId
may result in the firsttokenRecipient[]
being invalid, thus preventing the founder from obtaining this portion of the NFT.Vulnerability Detail
The current protocol adds a parameter
reservedUntilTokenId
for reservingToken
.This parameter will be used as the starting
baseTokenId
during initialization.Because
baseTokenId = reservedUntilTokenId
is used, ifreservedUntilTokenId>100
, for example, reservedUntilTokenId=200, the first_getNextTokenId(200)
will returnbaseTokenId=200 , tokenRecipient[200]=newFounder
.Example:
reservedUntilTokenId = 200
founder[0].founderPct = 10
In this way, the
tokenRecipient[]
offounder
will becometokenRecipient[200].wallet = founder ( first will call _getNextTokenId(200) return 200)
tokenRecipient[10].wallet = founder ( second will call _getNextTokenId((200 + 10) %100 = 10) )
tokenRecipient[20].wallet = founder
...
tokenRecipient[90].wallet = founder
However, this
tokenRecipient[200]
will never be used, because in_isForFounder()
, it will be modulo, so onlybaseTokenId < 100
is valid. In this way, the first founder can actually only9%
of NFT.POC
The following test demonstrates that
tokenRecipient[200]
is for founder.token.t.sol
Impact
when reservedUntilTokenId > 100 first funder loss 1% NFT
Code Snippet
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L161
Tool used
Manual Review
Recommendation
or
uint256 baseTokenId = reservedUntilTokenId % 100;
The text was updated successfully, but these errors were encountered: