Skip to content
Business logic Audit finding Intermediate

AuctionCrowdfund: If the contract was bid on before the NFT was gifted to the contract, lastBid will not be totalContributions

In the AuctionCrowdfund contract, if the NFT was gifted to the contract after a bid had already been placed, the finalize function would not treat it as a gift because lastBid_ was non-zero. As a result, only the initial bidder would win instead of all contributors.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

In the finalize function of the AuctionCrowdfund contract, when the contract gets NFT and lastBid_ == 0, it is considered that NFT is gifted to the contract and everyone who contributed wins.

        if (nftContract.safeOwnerOf(nftTokenId) == address(this)) {
            if (lastBid_ == 0) {
                // The NFT was gifted to us. Everyone who contributed wins.
                lastBid_ = totalContributions;

But if the contract was bid before the NFT was gifted to the contract, then since lastBid_ ! = 0, only the user who contributed at the beginning will win.

Proof of Concept

https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/crowdfund/AuctionCrowdfund.sol#L233-L242

https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/crowdfund/AuctionCrowdfund.sol#L149-L175

Recommended Mitigation Steps

Whether or not NFT is free to get should be determined using whether the contract balance is greater than totalContributions.

merklejerk (PartyDAO) confirmed and commented:

Gifted NFTs are expected to be an extremely exceptional (if ever) case, but we do want to make a best effort to make these situations somewhat fair to contributors. We will implement the recommendation and check that this.balance >= totalContributions to see if the NFT was acquired for free.

0xble (PartyDAO) resolved:

Resolved: https://github.com/PartyDAO/partybidV2/pull/133

HardlyDifficult (judge) commented:

This could be seen as a form of leaking value, agree with Medium risk.


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

Likely the contract uses lastBid_ == 0 to detect a gifted NFT, but lastBid_ can be non-zero from an earlier bid even when the NFT is later gifted.

Impact

Contributors other than the initial bidder could lose their chance to win the NFT, effectively leaking value from them.

What the attacker needed

NFT is gifted to the contract; a bid was placed before the gift

The fix

The contract should check whether its balance is at least totalContributions to determine if the NFT was acquired for free, rather than relying on lastBid_ == 0.

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 crowdfunding an NFT auction. If someone gives the NFT to the contract for free, the code is supposed to let everyone who contributed win. But if a bid happened first, the code mistakenly thinks the NFT was bought, so only the first bidder wins. That is unfair to other contributors.

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 cccz

View all

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

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.