Platform: Code4rena
Start Date: 03/07/2023
Pot Size: $100,000 USDC
Total HM: 4
Participants: 36
Period: 10 days
Judge: gzeon
Total Solo HM: 3
Id: 257
League: ETH
Rank: 14/36
Findings: 2
Award: $277.78
π Selected for report: 0
π Solo Findings: 0
π Selected for report: shark
Also found by: 0xMilenov, Bauchibred, Kaysoft, MohammedRizwan, codegpt, descharre, fatherOfBlocks, ihtishamsudo, klau5, koxuan, nadin
58.9765 USDC - $58.98
returnTokensToOwner
should emit and event for numTokensInEscrow -= tokenIds.length
Missing events for critical arithmetic parameters.
Without emitting an event for numTokensInEscrow
it would be difficult to track numTokensInEscrow
reduced by the number of tokenIds
especially in off-chain procedures, eventually results in wrong calculation in numTokensInEscrow
Encephalon aka Brain
NounsDAOForkEscrow.sol#L116-L125
Event should be defined in the contract i.e
event TokensReturnedToOwner(address indexed owner, uint256 numTokens);
And should be emit in the function in a way i.e
function returnTokensToOwner(address owner, uint256[] calldata tokenIds) external onlyDAO { for (uint256 i = 0; i < tokenIds.length; i++) { if (currentOwnerOf(tokenIds[i]) != owner) revert NotOwner(); nounsToken.transferFrom(address(this), owner, tokenIds[i]); escrowedTokensByForkId[forkId][tokenIds[i]] = address(0); } numTokensInEscrow -= tokenIds.length; // Emit that event for tracking changes emit TokensReturnedToOwner(owner, tokenIds.length); }
block.timestamp
for making decisions regarding governance could be problematicusage of block.timestamp
. block.timestamp
can be manipulated by miners.
Miners can manipulate the block timestamp to some extent. Which could Effect checkGovernanceActive()
function
Solidity Visual Developer
NounsDAOLogicV1Fork.sol#L377-L378 NounsDAOLogicV1Fork.sol#L377-L378
Avoid relying on block.timestamp.
transferred
once the block.number
passes type(uint32).max
Considering This Issue From Past Report Of Nouns DAO And Not Sure The Mitigation Is Done So Submitting Again, Feedback if mitigation is implemented because I have seen no changes.
While this currently equates to ~1260 years, if thereβs a hard fork which makes block times much more frequent (e.g. to compete with Solana), then this limit may be reached much faster than expected, and transfers and delegations will remain stuck at their existing settings
Past Report
#0 - c4-judge
2023-07-25T10:01:24Z
gzeon-c4 marked the issue as grade-b
π Selected for report: 0xnev
Also found by: 0xSmartContract, K42, Matin, ihtishamsudo, shark
Based On My Experience Auditing This Codebase I Will Answer The Analysis Questions.
The first thing I would like to mention is the complexity to clone this repo. Because of the symlinks
to libraries and tests, everything in the scope couldn't be clones using git clone
.
For Instance, to understand this, Whenever you want to clone the repo that was available for audit, the script folder is not fetched in the local environment i.e. in IDE like VS Code. I have to manually add the script folder by downloading it from Repo and, for forge tests, Lib was missing obviously Lib wasn't fetched either while git cloning
so had to manually import in my local environment, so it was kind of mess Setting up Repo in the local environment.
Now, Here's the point what is unique
in this codebase. The Nouns DAO is unique in its approach to NFT generation and governance. Unlike, An NFT Project, which has literally no use case just a random shit people wasting money on. Noun DAO is using attractive model For NFTs and a proper use case that is beneficial for creators and the people behind Noun DAO.
One more thing I like about this codebase and project is that the new version introduces several unique features like proposal editing and Nouns Fork.
The arcihtecture, to be honest, seems to be well-structured with clear separation of concerns. Transparent proxy being used that allows Governance
contract upgradability. But, transition from the current treasury to a new treasury could be a potential point of concern and needs to be handled carefully.And transition from the current treasury to a new treasury could be a potential point of concern and needs to be handled carefully. And I want to put some words about the Nouns DAO Fork
it seems like the Nouns Fork mechanism is designed with a lot of thought towards protecting minority token holders and ensuring fair governance. The two-phase process Escrow and Forking periods
allows for flexibility and gives token holders the ability to change their minds before the fork is finalized. However, the potential for an attacker to follow into the new forked DAO is a concern that might need further mitigation strategies. Hope so Many wardens, including me, have submitted many mitigations to improve this forking process.
The DAO model inherently reduces centralization risks as it is governed by token holders. However, the introduction of the Nouns Fork feature could potentially lead to fragmentation of the community if a significant minority
decides to exit the DAO.
One systemic risk could be the potential for a malicious majority to force a minority to fork and then join the fork with many of their tokens, continuing to attack the minority in their new fork DAO.
The transition from the current treasury to the new treasury should be handled with care to avoid any potential issues. Also, the potential issues with the Nouns Fork feature should be carefully considered and addressed.
I roughly spent 20-22 hours on this codebase, wanted to spend some more time on this interesting codebase but we all have priorities. Will be glad to secure this protocol again in near future.
20 hours
#0 - c4-judge
2023-07-25T10:25:15Z
gzeon-c4 marked the issue as grade-b