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
Token.updateFounders does not delete the old founder's vesting schedule.
Summary
Token.updateFounders does not delete the old founder's vesting schedule.
Vulnerability Detail
Add the following code in test/POC2.sol and run forge test --mt test_POC2 -vvv.
The test shows that if baseTokenId = (baseTokenId + schedule) % 100; rounds back to a smaller number than the first baseTokenId, updateFounders does not delete the old founder's baseTokenIds.
When I add import { console } from "forge-std/console.sol"; at Token.sol and add console.log in addFounders and updateFounders, I can see the following logs.
for (uint256 j; j < founderPct; ++j) {
// Get the available token id
baseTokenId =_getNextTokenId(baseTokenId);
// @audit Add this line
console.log("[_addFounders] baseTokenId: %s", baseTokenId);
for (uint256 j; j < cachedFounder.ownershipPct; ++j) {
// Get the next index that hasn't already been clearedwhile (clearedTokenIds[baseTokenId] !=false) {
baseTokenId = (++baseTokenId) %100;
}
delete tokenRecipient[baseTokenId];
// @audit Add this line
console.log("[updateFounders] baseTokenId: %s", baseTokenId);
clearedTokenIds[baseTokenId] =true;
sherlock-admin2
changed the title
Puny Flint Pony - Token.updateFounders does not delete the old founder's vesting schedule.
qpzm - Token.updateFounders does not delete the old founder's vesting schedule.
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
qpzm
high
Token.updateFounders
does not delete the old founder's vesting schedule.Summary
Token.updateFounders
does not delete the old founder's vesting schedule.Vulnerability Detail
Add the following code in
test/POC2.sol
and runforge test --mt test_POC2 -vvv
.The test shows that if
baseTokenId = (baseTokenId + schedule) % 100;
rounds back to a smaller number than the firstbaseTokenId
,updateFounders
does not delete the old founder'sbaseTokenId
s.When I add
import { console } from "forge-std/console.sol";
atToken.sol
and add console.log inaddFounders
andupdateFounders
, I can see the following logs.https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L164-L166
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L414-L421
$ forge test --mt test_POC2 -vvv Logs: [_addFounders] baseTokenId: 10 [_addFounders] baseTokenId: 19 [_addFounders] baseTokenId: 28 [_addFounders] baseTokenId: 37 [_addFounders] baseTokenId: 46 [_addFounders] baseTokenId: 55 [_addFounders] baseTokenId: 64 [_addFounders] baseTokenId: 73 [_addFounders] baseTokenId: 82 [_addFounders] baseTokenId: 91 [_addFounders] baseTokenId: 0 // This is deleted ids [updateFounders] baseTokenId: 0 [updateFounders] baseTokenId: 9 [updateFounders] baseTokenId: 18 [updateFounders] baseTokenId: 27 [updateFounders] baseTokenId: 36 [updateFounders] baseTokenId: 45 [updateFounders] baseTokenId: 54 [updateFounders] baseTokenId: 63 [updateFounders] baseTokenId: 72 [updateFounders] baseTokenId: 81 [updateFounders] baseTokenId: 90 // This is newly added ids [_addFounders] baseTokenId: 11 [_addFounders] baseTokenId: 20 [_addFounders] baseTokenId: 29 [_addFounders] baseTokenId: 38 [_addFounders] baseTokenId: 47 [_addFounders] baseTokenId: 56 [_addFounders] baseTokenId: 65 [_addFounders] baseTokenId: 74 [_addFounders] baseTokenId: 83 [_addFounders] baseTokenId: 92 [_addFounders] baseTokenId: 1
Impact
The old founder can still get token vesting unexpectedly.
Code Snippet
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L158-L176
https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L414-L428
Tool used
Manual Review, foundry
Recommendation
There are two solutions.
First, iterate from not
reservedUntilTokenId
, but0
inToken._addFounders
andToken.updateFounders
. This delays the founders' vesting a little.https://github.com/sherlock-audit/2023-09-nounsbuilder/blob/main/nouns-protocol/src/token/Token.sol#L161
After the fix above, run
forge test --mt test_POC2 -vvv
again.Second, if the logic becomes too complex, just iterate from 0 to 99 and delete if
tokenRecipient[baseTokenId].wallet != address(0)
.Duplicate of #42
The text was updated successfully, but these errors were encountered: