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

If auction market finalization always reverts, the fund will be locked in the Crowdfund contract forever. #254

Open
code423n4 opened this issue Sep 19, 2022 · 2 comments
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) 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/crowdfund/AuctionCrowdfund.sol#L212-L226

Vulnerability details

Impact

If auction market finalization always reverts, the fund will be locked in the Crowdfund contract forever. Even if CrowdfundLifecycle is expired. This causes fund loss.

If CrowdfundLifecycle is expired and we cannot finalize the auction, we should mark the crowdfund as "Lost" and return the fund to contributors.

Proof of Concept

        if (lastBid_ != 0) {
            uint256 auctionId_ = auctionId;
            // Finalize the auction if it isn't finalized.
            if (!market.isFinalized(auctionId_)) {
                // Note that even if this crowdfund has expired but the auction is still
                // ongoing, this call can fail and block finalization until the auction ends.
                (bool s, bytes memory r) = address(market).call(abi.encodeCall(
                    IMarketWrapper.finalize,
                    auctionId_
                ));
                if (!s) {
                    r.rawRevert();
                }
            }
        } else {
            // If we never placed a bid, the auction must have expired.
            if (lc != CrowdfundLifecycle.Expired) {
                revert AuctionNotExpiredError();
            }
        }
...
        } else {
            // Clear `lastBid` so `_getFinalPrice()` is 0 and people can redeem their
            // full contributions when they burn their participation NFTs.
            lastBid = 0;
            emit Lost();
        }

        _bidStatus = AuctionCrowdfundStatus.Finalized;

If IMarketWrapper.finalize call always revert, it will always skip the block that set lastBid to 0 and _bidStatus to Finalized. Result in crowdfund never finalized and fund of contributors will be locked in the AuctionCrowdfund contract forever

Tools Used

Manual review

Recommended Mitigation Steps

You should create an emergency switch that can be toggled when both crowdfund is expired and IMarketWrapper.finalize revert. And check for that emergency switch if it is toggled and IMarketWrapper.finalize reverts, you should mark the crowdfund as lost ignoring fund lost due to a bug in the target marketplace.

...
            if (!market.isFinalized(auctionId_)) {
                // Note that even if this crowdfund has expired but the auction is still
                // ongoing, this call can fail and block finalization until the auction ends.
                (bool s, bytes memory r) = address(market).call(abi.encodeCall(
                    IMarketWrapper.finalize,
                    auctionId_
                ));
                if (!s && !emergencySwitch) {
                    r.rawRevert();
                }
            }
        } else {
...
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Sep 19, 2022
code423n4 added a commit that referenced this issue Sep 19, 2022
@merklejerk merklejerk added sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 22, 2022
@merklejerk
Copy link
Collaborator

We're OK with this risk. It's something we look out for and handle inside market wrappers.

@HardlyDifficult
Copy link
Collaborator

The report here seems theoretically sound. However without context on which market / scenario could put the party into this state it's hard to support the suggested risk. Downgrading to Low risk, as described this is an additional safegaurd for consideration.

Downgrading and converting into a QA report for the warden.

@HardlyDifficult HardlyDifficult added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Sep 30, 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 disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) 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

3 participants