Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quorum() needs sanity check #471

Closed
code423n4 opened this issue Sep 15, 2022 · 1 comment
Closed

quorum() needs sanity check #471

code423n4 opened this issue Sep 15, 2022 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-09-nouns-builder/blob/7e9fddbbacdd7d7812e912a369cfd862ee67dc03/src/governance/governor/Governor.sol#L475

Vulnerability details

Impact

When NFT totalSupply is low, the quorum() might be more sensitive to rounding errors. Sometimes the error could be large, or even return 0 result. The vote results based on these quorum() will deviate from the intention of governance.

Proof of Concept

Any new bidder can call createBid() to place a bid:

// src/governance/governor/Governor.sol
    function quorum() public view returns (uint256) {
        unchecked {
            return (settings.token.totalSupply() * settings.quorumThresholdBps) / 10_000;
        }
    }

In test file, quorumThresholdBps is set to 2_000, then:

  • when totalSupply of NFT is less than 5, quorum() will return 0.
  • when totalSupply of NFT is 9, quorum() will return 1.

Seems the error is too big for small totalSupply and quorumThresholdBps.

Tools Used

Manual analysis.

Recommended Mitigation Steps

  • For low totalSupply, do additional checks for quorum() results, maybe round up.
  • Set minimum and maximum values for quorumThresholdBps in initialize() and updateProposalThresholdBps().
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Sep 15, 2022
code423n4 added a commit that referenced this issue Sep 15, 2022
@GalloDaSballo
Copy link
Collaborator

Dup of #604

@GalloDaSballo GalloDaSballo added the duplicate This issue or pull request already exists label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants