fix(bounties): only allow claiming a funded bounty (prevents payout for unfunded bounties)#36
Open
AliaksandrNazaruk wants to merge 1 commit into
Conversation
…or unfunded bounties)
POST /api/bounties/[id]/claim gated on status IN ('open','funded'). A bounty
is created 'open' and only becomes 'funded' after the CoinPay funding webhook
confirms the creator's payment. Accepting 'open' meant a bounty whose funding
was never completed (creator abandoned/failed the CoinPay checkout) could still
be claimed — and the claim path then prepares and broadcasts a real payout of
bounty.reward_usd from the merchant web wallet to the claimer.
Gate both the pre-check (line 23) and the atomic UPDATE ... WHERE (closing the
TOCTOU) on status = 'funded' so a payout can only fire after funding is
confirmed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
POST /api/bounties/[id]/claimacceptedstatus IN ('open','funded'). A bounty is createdopenand only becomesfundedafter the CoinPay funding webhook confirms the creator's payment. So an unfunded bounty (abandoned/failed creator checkout) could still be claimed — and the claim path then prepares + broadcasts a real payout ofbounty.reward_usdfrom the merchant web wallet to the claimer (see #35).Fix
Gate on
status = 'funded'in both places:if (bounty.status !== 'funded')UPDATE ... WHERE(line 38):AND status = 'funded'— closes the concurrent-flip TOCTOUA payout can now only fire after the funding webhook has set
funded. Two-line change, no behavior change for funded bounties.Fixes #35.