Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getMinimumBid can return invalid value for Zora #116

Closed
code423n4 opened this issue Sep 17, 2022 · 4 comments
Closed

getMinimumBid can return invalid value for Zora #116

code423n4 opened this issue Sep 17, 2022 · 4 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/market-wrapper/ZoraMarketWrapper.sol#L80

Vulnerability details

Impact & Proof Of Concept

getMinimumBid simply returns the reserve price (when there are no bidders) or the minimum increment. However, when the tokenContract is equal to the zora protocol (which is possible, as this is not disallowed by the Party protocol), there is an additional check in Zora's AuctionHouse:

        // For Zora Protocol, ensure that the bid is valid for the current bidShare configuration
        if(auctions[auctionId].tokenContract == zora) {
            require(
                IMarket(IMediaExtended(zora).marketContract()).isValidBid(
                    auctions[auctionId].tokenId,
                    amount
                ),
                "Bid invalid for share splitting"
            );
        }

Looking at Zora's Market, we can see that this checks if the amount is perfectly splittable:

    /**
     * @notice Validates that the bid is valid by ensuring that the bid amount can be split perfectly into all the bid shares.
     *  We do this by comparing the sum of the individual share values with the amount and ensuring they are equal. Because
     *  the splitShare function uses integer division, any inconsistencies with the original and split sums would be due to
     *  a bid splitting that does not perfectly divide the bid amount.
     */
    function isValidBid(uint256 tokenId, uint256 bidAmount)
        public
        view
        override
        returns (bool)
    {
        BidShares memory bidShares = bidSharesForToken(tokenId);
        require(
            isValidBidShares(bidShares),
            "Market: Invalid bid shares for token"
        );
        return
            bidAmount != 0 &&
            (bidAmount ==
                splitShare(bidShares.creator, bidAmount)
                    .add(splitShare(bidShares.prevOwner, bidAmount))
                    .add(splitShare(bidShares.owner, bidAmount)));
    }

It is therefore possible that the amount returned by getMinimumBid does not pass this check, which would mean that it is impossible to bid on this token (as Party protocol always uses the minimum amount and there is no way to pass an amount manually).

Recommended Mitigation Steps

Incorporate this into the getMinimumBid calculation. If tokenContract is equal to the Zora protocol, the amount returned has to be larger than the minimum increment AND perfectly splittable.

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Sep 17, 2022
code423n4 added a commit that referenced this issue Sep 17, 2022
@merklejerk merklejerk added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Sep 21, 2022
@merklejerk
Copy link
Collaborator

Will fix in the future. For now, the FE can block zora tokens from the FE to mitigate.

@HardlyDifficult
Copy link
Collaborator

Interesting limitation that could interfere with Zora NFT support. Agree with Medium risk.

@trust1995
Copy link

A cool find. While wondering why I didn't find it myself, I re-checked the scope for the contest and indeed, all the MarketWrappers are explicitly out of scope. So while it is a commendable submission, I think for fairness sake it needs to be closed.

image
@HardlyDifficult

@HardlyDifficult
Copy link
Collaborator

That's a good flag, thanks @trust1995 . I will lower severity since this was out of scope. Merging with #101

@HardlyDifficult HardlyDifficult added duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

4 participants