Skip to content
Business logic Audit finding Intermediate

`queue()` should increase `proposalsPassed` instead of `proposalsCreated`

The queue() function incremented the proposalsCreated counters for the proposer and the community instead of the proposalsPassed counters. Because the two counters can have different multipliers, the proposer's voting power bonus was calculated incorrectly.

WatchPug Follow with neumo, hansfriese and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-frankendao-judging/issues/54

Found by

WATCHPUG, neumo, hansfriese, rvierdiiev, 0x52, cccz, Trumpero, John

Summary

proposalsCreated will be increased in verifyProposal(), queue() should increase proposalsPassed.

Vulnerability Detail

Based on the context, queue() should increase userCommunityScoreData[proposal.proposer].proposalsPassed and totalCommunityScoreData.proposalsPassed instead.

Impact

Due to the presence of setProposalsCreatedMultiplier() and setProposalsPassedMultiplier(), the multiplier of both scores can be different, when that's the case, the proposer's voting power bonuses will be wrongly calculated because proposalsPassed is not correctly increased in queue().

Code Snippet

https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Governance.sol#L467-L495

https://github.com/sherlock-audit/2022-11-frankendao/blob/main/src/Staking.sol#L592-L601

Tool used

Manual Review

Recommendation

Change to:

Diff
    function queue(uint256 _proposalId) external {
        // Succeeded means we're past the endTime, yes votes outweigh no votes, and quorum threshold is met
        if(state(_proposalId) != ProposalState.Succeeded) revert InvalidStatus();
        
        Proposal storage proposal = proposals[_proposalId];

        // Set the ETA (time for execution) to the soonest time based on the Executor's delay
        uint256 eta = block.timestamp + executor.DELAY();
        proposal.eta = eta.toUint32();

        // Queue separate transactions for each action in the proposal
        uint numTargets = proposal.targets.length;
        for (uint256 i = 0; i < numTargets; i++) {
            executor.queueTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
        }

        // If a proposal is queued, we are ready to award the community voting power bonuses to the proposer
-        ++userCommunityScoreData[proposal.proposer].proposalsCreated;
+        ++userCommunityScoreData[proposal.proposer].proposalsPassed;

        // We don't need to check whether the proposer is accruing community voting power because
        // they needed that voting power to propose, and once they have an Active Proposal, their
        // tokens are locked from delegating and unstaking.
-        ++totalCommunityScoreData.proposalsCreated;
+        ++totalCommunityScoreData.proposalsPassed;
        
        // Remove the proposal from the Active Proposals array
        _removeFromActiveProposals(_proposalId);

        emit ProposalQueued(_proposalId, eta);
    }

Discussion

ZakkMan

Fixed: https://github.com/Solidity-Guild/FrankenDAO/pull/20

jack-the-pug

Fix confirmed

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

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 a copy-paste or logic slip where queue() incremented the proposalsCreated counters rather than the proposalsPassed counters.

Impact

When the created and passed multipliers differ, the proposer's voting power bonuses could be calculated incorrectly.

What the attacker needed

A proposal reaches Succeeded state; created and passed multipliers differ

The fix

The counters in queue() were changed to increment proposalsPassed, and the fix was confirmed.

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.

This is a smart contract for a voting system. When a proposal passes and is queued for execution, the contract is meant to reward the person who made it by raising a 'proposals passed' score, which feeds into their voting power. Instead it raised a different score, 'proposals created', so the reward was worked out wrongly.

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 WatchPug

View all

197 more disclosed reports, best first.

More from FrankenDAO

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.