Skip to content
Smart contracts Audit finding Intermediate

PartyGovernanceNFT advertises but does not honor the ERC-4906 standard

The PartyGovernanceNFT contract claims to support ERC-4906 but does not emit the required MetadataUpdate or BatchMetadataUpdate events when voting power changes, which alters the NFT metadata. As a result, off-chain platforms like marketplaces or block explorers may display stale metadata, potentially allowing tokens to be sold at inflated prices.

3docSec Follow with pep7siup, Bauchibred and 1 other

Originally disclosed on Code4rena

Submitted by 3docSec, also found by pep7siup, Bauchibred, and lsaudit

Lines of code

https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/party/PartyGovernanceNFT.sol#L208 https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/party/PartyGovernanceNFT.sol#L236 https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/party/PartyGovernanceNFT.sol#L247 https://github.com/code-423n4/2023-10-party/blob/b23c65d62a20921c709582b0b76b387f2bb9ebb5/contracts/party/PartyGovernanceNFT.sol#L255

Vulnerability details

The PartyGovernanceNFT contract inherits from PartyGovernance, and through it, it advertises support for the ERC-4906 standard:

    // PartyGovernance.sol:333

    function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
        return
            interfaceId == type(IERC721Receiver).interfaceId ||
            interfaceId == type(ERC1155TokenReceiverBase).interfaceId ||
            // ERC4906 interface ID
            interfaceId == 0x49064906;
    }

Because of this, consumers like NFT marketplaces or block explorer expect updates from PartyGovernanceNFT in the form of MetadataUpdate or BatchMetadataUpdate events whenever the metadata of its NFTs changes.

The protocol has a default implementation of Party metadata, which, among other information, includes voting power:

                // PartyNFTRenderer.sol:292
                string.concat(
                    "This membership represents ",
                    generateVotingPowerPercentage(tokenId),
                    "% voting power in ",
                    partyName,
                    ". Head to ",
                    generateExternalURL(),
                    " to view the Party's latest activity."
                );

Consequently, the metadata is expected to change whenever a single NFT’s voting power, or the contract’s total voting power are updated. However, when this happens, no MetadataUpdate or BatchMetadataUpdate event is raised.

The following vote-share (and consequently metadata) changing functions have been identified, and none emits the required events:

    // PartyGovernanceNFT.sol:208
    function increaseVotingPower(uint256 tokenId, uint96 votingPower) external {
        // [...]
        emit PartyCardIntrinsicVotingPowerSet(tokenId, newIntrinsicVotingPower);

        _adjustVotingPower(ownerOf(tokenId), votingPower.safeCastUint96ToInt192(), address(0));
    }
    // PartyGovernanceNFT.sol:236
    function decreaseVotingPower(uint256 tokenId, uint96 votingPower) external {
        _assertAuthority();
        mintedVotingPower -= votingPower;
        votingPowerByTokenId[tokenId] -= votingPower;

        _adjustVotingPower(ownerOf(tokenId), -votingPower.safeCastUint96ToInt192(), address(0));
    }
    // PartyGovernanceNFT.sol:247
    function increaseTotalVotingPower(uint96 votingPower) external {
        _assertAuthority();
        _getSharedProposalStorage().governanceValues.totalVotingPower += votingPower;
    }
    // PartyGovernanceNFT.sol:255
    function decreaseTotalVotingPower(uint96 votingPower) external {
        _assertAuthority();
        _getSharedProposalStorage().governanceValues.totalVotingPower -= votingPower;
    }

As a consequence, off-chain platforms like NFT marketplaces or block explorers may show stale metadata for the NFTs, and token holders can use this stale data to their advantage.

To add context, openness to having PartyGovernanceNFT tokens traded on a marketplace seems a reasonable use case since the team opted for implementing the ERC-2981 standard for PartyGovernanceNFT tokens.

Impact

PartyGovernanceNFT tokens may be exchanged for inflated prices on platforms showing stale data.

Proof of Concept

Starting with a PartyGovernanceNFT (after crowdfunding is finalized) that delegates its tokenURI to a PartyNFTRenderer contract:

  • Create an NFT, and hash its tokenURI.

  • Call increaseVotingPower or decreaseVotingPower for the given NFT:

    • Hash again the NFT tokenURI and observe how it’s changed.
    • However no MetadataUpdate was called.
  • Call increaseTotalVotingPower or decreaseTotalVotingPower.

    • Hash again the NFT tokenURI and observe how it’s changed.
    • However no BatchMetadataUpdate was called.

Tools Used

Foundry

Recommended Mitigation Steps

Consider updating:

  • PartyGovernanceNFT.increaseVotingPower to emit a MetadataUpdate event.
  • PartyGovernanceNFT.decreaseVotingPower to emit a MetadataUpdate event.
  • PartyGovernanceNFT.increaseTotalVotingPower to emit a BatchMetadataUpdate event.
  • PartyGovernanceNFT.decreaseTotalVotingPower to emit a BatchMetadataUpdate event.

Assessed type

ERC721

gzeon (judge) commented:

Judging as Med due to broken support of ERC4960

  • PartyGovernance: Should comply with ERC4906

0xble (Party) confirmed


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

The contract implements the ERC-4906 interface but fails to emit the required MetadataUpdate and BatchMetadataUpdate events in functions that change voting power and thus the token metadata.

Impact

PartyGovernanceNFT tokens may be exchanged for inflated prices on platforms showing stale data.

What the attacker needed

PartyGovernanceNFT with tokenURI delegated to renderer; NFT listed on a platform that relies on ERC-4906 events

The fix

The contract should emit MetadataUpdate in increaseVotingPower and decreaseVotingPower, and BatchMetadataUpdate in increaseTotalVotingPower and decreaseTotalVotingPower.

How it was found

  1. Create an NFT and hash its tokenURI.
  2. Call increaseVotingPower or decreaseVotingPower for the NFT.
  3. Hash the tokenURI again and observe it has changed, but no MetadataUpdate event was emitted.
  4. Call increaseTotalVotingPower or decreaseTotalVotingPower.
  5. Hash the tokenURI again and observe it has changed, but no BatchMetadataUpdate event was emitted.

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.

ERC-4906 is a standard that tells marketplaces and block explorers to refresh an NFT's displayed information when it changes. This contract says it follows that standard but never sends the update signals, so the displayed information can become out of date. Someone could then sell an NFT at a price that does not reflect its current voting power.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 3docSec

View all

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

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.