Skip to content

fix(bounties): disallow transition from MERGED to REFUNDED (Fixes #795) - #859

Open
yunyue-taste-it wants to merge 1 commit into
MergeFi:mainfrom
yunyue-taste-it:fix/issue-795-disallow-merged-to-refunded
Open

yunyue-taste-it wants to merge 1 commit into
MergeFi:mainfrom
yunyue-taste-it:fix/issue-795-disallow-merged-to-refunded

Conversation

@yunyue-taste-it

Copy link
Copy Markdown

Summary

Fixes #795.

Eliminates the state-machine vulnerability where bounties in the MERGED status could transition to REFUNDED, preventing sponsors or repository maintainers from retracting funds after a contributor's pull request has been accepted and merged on GitHub.

Root Cause

  • In src/bounties/bounty-state-machine.ts, the transition mapping previously defined:
    [BountyStatus.MERGED]: [
      BountyStatus.PAID,
      BountyStatus.RELEASE_FAILED,
      BountyStatus.REFUNDED,
    ],
  • Once a pull request is merged on GitHub, the contributor has fulfilled their commitment and their work has landed into the upstream codebase. Allowing MERGED -> REFUNDED enabled sponsors and repository maintainers to initiate a refund after work completion, denying contributors their earned payout.
  • Once merged, the only legitimate outcomes are PAID (successful escrow release) and RELEASE_FAILED (transient release failure allowing subsequent retry).

Technical Changes

  1. State Machine Hardening (src/bounties/bounty-state-machine.ts):
    • Removed BountyStatus.REFUNDED from BOUNTY_TRANSITIONS[BountyStatus.MERGED].
  2. Unit Test Coverage (src/bounties/bounty-state-machine.spec.ts):
    • Removed MERGED from allowed refund statuses in test fixtures.
    • Added unit test asserting canTransition(BountyStatus.MERGED, BountyStatus.REFUNDED) === false and that assertTransition(BountyStatus.MERGED, BountyStatus.REFUNDED) throws InvalidBountyTransitionError.

Verification

  • src/bounties/bounty-state-machine.spec.ts passes 100% (9/9 tests passing).
  • bounties.refund-auth.spec.ts and bounties.query.spec.ts pass 100% (6/6 tests passing).

Bounty Payout Address

  • Base / EVM Wallet (USDC): 0x53A47C81DdaCEDFba1048842D5D5f011a80e386D

@vercel

vercel Bot commented Nov 12, 2026

Copy link
Copy Markdown

@yunyue-taste-it is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The bounty state machine allows MERGED → REFUNDED, so a completed bounty's funds can be returned to the sponsor

1 participant