Skip to content
Business logic Audit finding Intermediate

PartyGovernance.sol#accept - passThresholdBps isn’t cached for each proposal which can lead to problems if changed through another proposal

The governance contract uses the current global pass threshold when checking if a proposal has passed, rather than the threshold that was in effect when the proposal was created. An attacker could change the threshold through a separate proposal to make an unpopular proposal pass or to block a popular one.

TresDelinquentes Follow with KupiaSec, cccz and 1 other

Originally disclosed on Code4rena

Submitted by TresDelinquentes, also found by KupiaSec, cccz, and 0xbrett8571

PartyGovernance uses a variable called passThresholdBps to determine the percentage of votes from the totalVotingPower a proposal needs to receive so it can pass.

The protocol also allows parties to change several governance options through SetGovernanceParameterProposal, including passThresholdBps.

    /// @notice Execute a `SetGovernanceParameterProposal` which sets the given governance parameter.
    function _executeSetGovernanceParameter(
        IProposalExecutionEngine.ExecuteProposalParams memory params
    ) internal returns (bytes memory) {
        SetGovernanceParameterProposalData memory proposalData = abi.decode(
            params.proposalData,
            (SetGovernanceParameterProposalData)
        );
        if (proposalData.voteDuration != 0) {
            if (proposalData.voteDuration < 1 hours) { //@audit can be really fkin big
                revert InvalidGovernanceParameter(proposalData.voteDuration);
            }
            emit VoteDurationSet(
                _getSharedProposalStorage().governanceValues.voteDuration,
                proposalData.voteDuration
            );
            _getSharedProposalStorage().governanceValues.voteDuration = proposalData.voteDuration;
        }
        if (proposalData.executionDelay != 0) {
            if (proposalData.executionDelay > 30 days) {
                revert InvalidGovernanceParameter(proposalData.executionDelay);
            }
            emit ExecutionDelaySet(
                _getSharedProposalStorage().governanceValues.executionDelay,
                proposalData.executionDelay
            );
            _getSharedProposalStorage().governanceValues.executionDelay = proposalData
                .executionDelay;
        }
        if (proposalData.passThresholdBps != 0) { // passThresholdBps can be set as well
            if (proposalData.passThresholdBps > 10000) {
                revert InvalidGovernanceParameter(proposalData.passThresholdBps);
            }
            emit PassThresholdBpsSet(
                _getSharedProposalStorage().governanceValues.passThresholdBps,
                proposalData.passThresholdBps
            );
            _getSharedProposalStorage().governanceValues.passThresholdBps = proposalData
                .passThresholdBps;
        }

        return "";
    }

This isn’t in itself a problem, but the logic for checking if a proposal has passed contains a problem. Inside accept, we have a check called _areVotesPassing, which compares if the votes of the proposal, compared to the cached totalVotingPower of the proposal passes passThresholdBps. The issue is that we are using the global passThresholdBps, not a cached one.

        ...
        // Update the proposal status if it has reached the pass threshold.
        if (
            values.passedTime == 0 &&
            _areVotesPassing(
                values.votes,
                values.totalVotingPower,
                _getSharedProposalStorage().governanceValues.passThresholdBps // This isn't cached
            )
        ) {
            info.values.passedTime = uint40(block.timestamp);
            emit ProposalPassed(proposalId);
            // Notify third-party platforms that the governance NFT metadata has
            // updated for all tokens.
            emit BatchMetadataUpdate(0, type(uint256).max);
        }

This can lead to unwanted behavior during the voting lifecycle of a proposal and can even be exploited by party members to their gain.

Proof of Concept

Let’s imagine a couple of scenarios:

Scenario A - passThresholdBps = 0.5e4 (50%)

  1. Alice and Bob are friends and hold about 30% of the voting power of the Party.
  2. Alice creates a proposal (proposal A), but Bob doesn’t accept it yet. The other users, refuse to accept the proposal.
  3. Alice and Bob create a second proposal (proposal B) to set passThresholdBps = 0.3e4(30%).
  4. Since the proposal will allow more freedom in the party for all users to pass their proposals, proposal B easily passes.
  5. Now the passThresholdBps = 0.3e4 (30%) and Bob calls accept on proposal A, passing it.

Scenario B - Reverse of Scenario A - passThresholdBps = 0.5e4 (50%)

  1. A proposal is created (proposal A) and it accumulates 40% votes. Since it’s not a very popular proposal, we’ll assume that it won’t accumulate more than 60% votes total, which is still enough for it to pass at this time.
  2. Another proposal is created (proposal B), which sets passThresholdBps = 0.7e4 (70%).
  3. Proposal A will now never pass, even if it accumulates 60% of the votes, since passThresholdBps = 0.7e4 (70%) it will never pass.

The actual creation of the proposals doesn’t matter. Proposal B can be proposed before proposal A, as long as it gets executed first, it will have an effect on all previous proposals.

The scenarios here are endless: from grieving other users, maliciously exploiting the issue to get unpopular, unfavorable proposals to pass or blocking proposals that would have otherwise passed.

This also introduces more attack vectors for a 51% attack, as someone that has let’s say 60% of the voting power, can just set passThresholdBps = 0.6e4 (60%) and easily block other users from getting their proposals accepted, while theirs will always pass.

Keep in mind that even completely non-malicious Parties can be affected by this negatively, as it introduces uncertainty and confusion during the voting stage.

Recommended Mitigation Steps

We recommend caching passThresholdBps in a similar way as totalVotingPower is cached for proposals.

0xble (Party) confirmed


The original report as published on Code4rena, by TresDelinquentes. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the pass threshold is read from global storage at the time of the vote check instead of being cached per proposal when the proposal is created.

Impact

A party member could manipulate the pass threshold to force through an unpopular proposal or to block a proposal that would otherwise have passed, and this could also enable a 51% attack.

What the attacker needed

A party member with enough voting power; ability to create and pass a governance parameter proposal

The fix

The pass threshold should be cached per proposal when the proposal is created, in the same way as totalVotingPower is cached.

How it was found

  1. Alice creates a proposal (proposal A) but it does not get enough votes to pass under the current threshold.
  2. Alice and Bob create a second proposal (proposal B) to lower the pass threshold.
  3. Proposal B passes and the global pass threshold is lowered.
  4. Bob calls accept on proposal A, which now passes because the lower threshold is used.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A proposal needs a certain percentage of votes to pass. That percentage can be changed by another vote. The bug is that when checking if a proposal has enough votes, the contract uses the latest percentage, not the one that was set when the proposal started. So someone could lower the percentage to push through a proposal that should have failed, or raise it to block a proposal that should have passed.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by TresDelinquentes

View all

4 more disclosed reports, best first.

More from Party Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.