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
increaseVotingPowerordecreaseVotingPowerfor the given NFT:- Hash again the NFT
tokenURIand observe how it’s changed. - However no
MetadataUpdatewas called.
- Hash again the NFT
-
Call
increaseTotalVotingPowerordecreaseTotalVotingPower.- Hash again the NFT
tokenURIand observe how it’s changed. - However no
BatchMetadataUpdatewas called.
- Hash again the NFT
Tools Used
Foundry
Recommended Mitigation Steps
Consider updating:
PartyGovernanceNFT.increaseVotingPowerto emit aMetadataUpdateevent.PartyGovernanceNFT.decreaseVotingPowerto emit aMetadataUpdateevent.PartyGovernanceNFT.increaseTotalVotingPowerto emit aBatchMetadataUpdateevent.PartyGovernanceNFT.decreaseTotalVotingPowerto emit aBatchMetadataUpdateevent.
Assessed type
ERC721
Judging as Med due to broken support of ERC4960
PartyGovernance: Should comply withERC4906
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
- Create an NFT and hash its tokenURI.
- Call increaseVotingPower or decreaseVotingPower for the NFT.
- Hash the tokenURI again and observe it has changed, but no MetadataUpdate event was emitted.
- Call increaseTotalVotingPower or decreaseTotalVotingPower.
- 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.