Skip to content

Add cross-cutting reentrancy_guard wrapping around external SAC transfers in withdraw and distribute_payouts #557

@greatest0fallt1me

Description

@greatest0fallt1me

Description

The reentrancy_guard module exposes with_external_call/before_external_call/after_external_call, but it must actually wrap every cross-contract token transfer. withdraw, claim_winnings, distribute_payouts, and withdraw_collected_fees perform SAC transfer calls that should follow checks-effects-interactions and be guarded so a malicious token cannot re-enter mid-payout.

Requirements and Context

  • Identify all external transfer calls in contracts/predictify-hybrid/src/lib.rs / bets.rs / fees.rs.
  • Apply state mutation before the transfer and wrap the transfer in ReentrancyGuard::with_external_call.
  • Ensure guard state is restored on transfer failure.
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b task/reentrancy-guard-transfers
  2. Implement changes
    • contracts/predictify-hybrid/src/lib.rs, contracts/predictify-hybrid/src/bets.rs, contracts/predictify-hybrid/src/fees.rs, contracts/predictify-hybrid/src/reentrancy_guard.rs
  3. Test and commit
    • cargo test -p predictify-hybrid -- reentrancy
    • Cover edge cases: re-entrant token mock, transfer failure rollback
    • Include test output and notes in the PR

Example commit message

task: guard external token transfers against reentrancy

Acceptance Criteria

  • All payout/withdraw transfers follow checks-effects-interactions
  • Transfers are wrapped by the reentrancy guard
  • A re-entrant token mock cannot double-spend in tests

Guidelines

  • Minimum 95% coverage on touched code, validate reentrancy-equivalent assumptions
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programsecuritySecurity hardeningsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions