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.
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
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 >= totalContributionsto see if the NFT was acquired for free.
HardlyDifficult (judge) commented:
This could be seen as a form of leaking value, agree with Medium risk.
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.