code-423n4 / 2023-05-maia-findings

20 stars 12 forks source link

When `totalSupply` is low `getProposalThresholdAmount()` and `getQuorumVotesAmount()` can return zero #876

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-05-maia/blob/cfed0dfa3bebdac0993b1b42239b4944eb0b196c/src/governance/GovernorBravoDelegateMaia.sol#L87-L93

Vulnerability details

Impact

At the early stage of the deployed DAO, it is possible that the following getProposalThresholdAmount() and getQuorumVotesAmount() returns 0 because the token supply is low.

Proof of Concept

LINK TO CODE

    function getProposalThresholdAmount() public view returns (uint256) {
        return govToken.totalSupply() * proposalThreshold / DIVISIONER;
    }

    function getQuorumVotesAmount() public view returns (uint256) {
        return govToken.totalSupply() * quorumVotes / DIVISIONER;
    }

Assume the effect when getQuorumVotesAmount() = 0:

Tools Used

Manual Review

Recommended Mitigation Steps

Make both functions return some sensible MIN_VALUE if they amount to 0.

Assessed type

Math

c4-judge commented 1 year ago

trust1995 changed the severity to QA (Quality Assurance)

c4-judge commented 1 year ago

trust1995 marked the issue as grade-c

Nadinnnn commented 1 year ago
c4-judge commented 1 year ago

This previously downgraded issue has been upgraded by trust1995

c4-judge commented 1 year ago

This previously downgraded issue has been upgraded by trust1995

c4-judge commented 1 year ago

trust1995 marked the issue as duplicate of #180

c4-judge commented 1 year ago

trust1995 marked the issue as satisfactory

0xLightt commented 1 year ago

This is not a duplicate of #180, which describes a race condition between minting bHermes and creating a proposal. This issue describes early governance stages of a protocol. In our scenario, this will never happen with bHermes and would require an error in migration to V2 to happen with Maia/vMaia.

While the mitigation is completely valid and works, having a MIN_TOTAL_SUPPLY is equivalent and easier to visualize in my opinion. The reason behind this might being a low/QA, is because what we intend to do and that completely prevents this is only calling _initiate after a certain amount of totalSupply exists. So might be argued that this can only happen due to api misuse by the owner, but adding the minimum value is still valid just to be safe.

In addition, there is the ability for the admin to veto proposals, so this further prevents anyone from using this to try and do a governance attack.

c4-judge commented 1 year ago

trust1995 marked the issue as not a duplicate

c4-judge commented 1 year ago

trust1995 changed the severity to QA (Quality Assurance)