ArtPiece.totalVotesSupply and ArtPiece.quorumVotes are incorrectly calculated due to inclusion of the inaccessible voting powers of the NFT that is being auctioned at the moment when an art piece is created
When an art piece is created, its total vote supply and quorum are calculated using the total supply of ERC721 voting tokens, which includes the NFT currently on auction that cannot be used to vote. This makes the quorum higher than intended and harder to reach, especially early in the protocol.
osmanozdemir1 Follow with hals, 0xG0P1 and 4 others
Originally disclosed on Code4rena
Submitted by osmanozdemir1, also found by hals, 0xG0P1, King_, SpicyMeatball, ktg, and rvierdiiev
In this protocol, art pieces are uploaded, voted on by the community and auctioned. Being the highest-voted art piece is not enough to go to auction, and that art piece also must reach the quorum.
The quorum for the art piece is determined according to the total vote supply when the art piece is created. This total vote supply is calculated according to the current supply of the erc20VotingToken and erc721VotingToken. erc721VotingTokens have weight compared to regular erc20VotingTokens and ERC721 tokens give users much more voting power.
file: CultureIndex.sol
function createPiece ...{
// ...
newPiece.totalVotesSupply = _calculateVoteWeight(
erc20VotingToken.totalSupply(),
--> erc721VotingToken.totalSupply() //@audit-issue This includes the erc721 token which is currently on auction. No one can use that token to vote on this piece.
);
// ...
--> newPiece.quorumVotes = (quorumVotesBPS * newPiece.totalVotesSupply) / 10_000; //@audit quorum votes will also be higher than it should be.
// ...
}
_calculateVoteWeight function:
function _calculateVoteWeight(uint256 erc20Balance, uint256 erc721Balance) internal view returns (uint256) {
return erc20Balance + (erc721Balance * erc721VotingTokenWeight * 1e18);
}
As I mentioned above, totalVotesSupply and quorumVotes of an art piece are calculated when the art piece is created based on the total supplies of the erc20 and erc721 tokens.
However, there is an important logic/context issue here.
This calculation includes the erc721 verbs token which is currently on auction and sitting in the AuctionHouse contract. The voting power of this token can never be used for that art piece because:
AuctionHousecontract obviously can not vote.- The future buyer of this NFT also can not vote since users’ right to vote is determined based on the creation block of the art piece.
In the end, totally inaccessible voting powers are included when calculating ArtPiece.totalVotesSupply and ArtPiece.quorumVotes, which results in incorrect quorum requirements and makes it harder to reach the quorum.
Impact
- Quorum vote requirements for created art pieces will be incorrect if there is an ongoing auction at the time the art piece is created.
- This will make it harder to reach the quorum.
- Unfair situations can occur between two art pieces (different totalVotesSuppy, different quorum requirements, but the same accessible/actual vote supply)
I also would like to that add the impact of this issue is not linear. It will decrease over time with the erc721VotingToken supply starts to increase day by day.
The impact is much higher in the early phase of the protocol, especially in the first days/weeks after the protocol launch where the verbsToken supply is only a handful.
Proof of Concept
Let’s assume that:
-The current erc20VotingToken supply is 1000 and it won’t change for this scenario.
-The weight of erc721VotingToken is 100.
-quorumVotesBPS is 5000 (50% quorum required)
Day 0: Protocol Launched
- Users started to upload their art pieces.
- There is no NFT minted yet.
- The total votes supply for all of these art pieces is 1000.
Day 1: First Mint
- One of the art pieces is chosen.
- The art piece is minted in
VerbsTokencontract and transferred toAuctionHousecontract. - The auction has started.
erc721VotingTokensupply is 1 at the moment.- Users keep uploading art pieces for the next day’s auction.
- For these art pieces uploaded on day 1:
totalVotesSupplyis 1100quorumVotesis 550 Accessible vote supply is still 1000. - According to accessible votes, the quorum rate is 55% not 50.
Day 2: Next Day
- The auction on the first day is concluded and transferred to the buyer.
- The next
verbsTokenis minted and the auction is started. erc721VotingTokensupply is 2.- Users keep uploading art pieces for the next day’s auction.
- For these art pieces uploaded on day 2:
totalVotesSupplyis 1200quorumVotesis 600 Accessible vote supply is 1100. (1000 + 100 from the buyer of the first NFT) - The actual quorum rate for these art pieces is ~54.5% (600 / 1100).
NOTE: The numbers used here are just for demonstration purposes. The impact will be much much higher if the erc721VotingToken weight is a bigger value like 1000.
Recommended Mitigation Steps
I strongly recommend subtracting the voting power of the NFT currently on auction when calculating the vote supply of the art piece and the quorum requirements.
// Note: You will also need to store auctionHouse contract address
in this contract.
+ address auctionHouse;
function createPiece () {
...
newPiece.totalVotesSupply = _calculateVoteWeight(
erc20VotingToken.totalSupply(),
- erc721VotingToken.totalSupply()
+ // Note: We don't subtract 1 as fixed amount in case of auction house being paused and not having an NFT at that moment. We only subtract if there is an ongoing auction.
+ erc721VotingToken.totalSupply() - erc721VotingToken.balanceOf(auctionHouse)
);
...
}
@rocketman-21 Requesting additional sponsor input on this one. This seems to be valid to me after a first review.
rocketman-21 (Revolution) confirmed and commented:
Super valid ty sirs.
0xTheC0der (Judge) increased severity to High and commented:
Severity increase was discussed with sponsor privately.
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 quorum calculation includes the voting power of the NFT held by the auction house, which cannot be used to vote on the new piece.
Impact
Quorum requirements for new art pieces are higher than they should be when an auction is ongoing, making it harder to reach quorum and creating unfair differences between pieces; the effect is larger early on when few NFTs exist.
What the attacker needed
An ongoing auction at the time an art piece is created; ERC721 voting tokens have non-zero weight
The fix
The calculation should subtract the voting power of the NFT currently held by the auction house when computing the total vote supply and quorum.
How it was found
- Assume a fixed ERC20 voting token supply and a set ERC721 weight and quorum percentage.
- On day 0, before any NFT is minted, art pieces are created with a total vote supply equal to the ERC20 supply.
- On day 1, an art piece is minted and transferred to the auction house, increasing the ERC721 supply by one.
- New art pieces created during the auction have their total vote supply and quorum increased by the weight of that one NFT, even though it cannot be used to vote.
- On day 2, after the auction concludes and the NFT is transferred to the buyer, the next NFT is minted and auctioned, again inflating the quorum for new pieces.
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.
In this system, people vote on art using two kinds of tokens: a regular token and a special NFT token that gives extra voting power. When a new art piece is added, the system sets a minimum number of votes needed to win (the quorum) based on all tokens that exist. But one of those special NFTs is locked in an auction and cannot be used to vote, so the minimum is set too high and is harder to reach.
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.