Skip to content

fix: contract address guard, re-entrancy protection, dispute-locked refund, and BPS sum validation#458

Merged
Ibinola merged 1 commit into
Lead-Studios:mainfrom
prismn:feature/security-fixes-434-431-428-425
Jun 29, 2026
Merged

fix: contract address guard, re-entrancy protection, dispute-locked refund, and BPS sum validation#458
Ibinola merged 1 commit into
Lead-Studios:mainfrom
prismn:feature/security-fixes-434-431-428-425

Conversation

@prismn

@prismn prismn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR addresses four security and correctness issues across the contract:

Changes

#434 — Prevent tokens being sent to the contract address via transfer and mint

  • Added InvalidRecipient guard in transfer (was missing; already present in transfer_from and mint for the minting path)
  • Tokens sent directly to the contract address become permanently unrecoverable; users must use create_escrow instead

#431 — Re-entrancy protection in distribute

  • Moved record.distributed = true and the storage write to BEFORE the distribution loop
  • Any re-entrant call to distribute now sees distributed = true immediately and panics, closing the double-distribution window

#428 — Block refund_escrow when a dispute is active

  • Added check in try_refund_escrow for an open EscrowDispute record
  • Depositor can no longer bypass dispute resolution by self-refunding; panics with DisputeOpen
  • Added test test_refund_escrow_with_open_dispute_panics

#425 — Validate that share_bps values sum to exactly 10000 in create_split

  • Validation already present; added the required named tests:
    test_create_split_shares_sum_to_10000_ok, test_create_split_shares_sum_to_9999_panics, test_create_split_shares_sum_to_10001_panics

Also fixed pre-existing compilation errors in the upstream branch (duplicate imports, duplicate enum variants, symbol length violations, missing imports) to restore a clean library build.


Closes #434
Closes #431
Closes #428
Closes #425

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@prismn Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ibinola Ibinola merged commit d06d12a into Lead-Studios:main Jun 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment