Skip to content

Reentrancy Guard for Payout Functions #479

Description

@Kingsman-99

Description

Token transfer callbacks in Soroban can re-enter the contract if the token contract is malicious or misconfigured. The release_payment and cancel_invoice functions must be protected by a reentrancy lock to prevent state corruption from recursive calls.

Technical Context

Store a ReentrancyLock boolean in storage::temporary in contracts/split/src/lib.rs. Introduce a with_reentrancy_guard closure wrapper that sets the flag on entry, runs the body, then clears it. Call env.storage().temporary() so the lock is automatically dropped at transaction boundary. Return ReentrantCall error on attempted reentry.

Acceptance Criteria

  • Nested calls to release_payment within the same transaction return ReentrantCall
  • The lock is cleared after successful execution so subsequent independent calls work
  • Temporary storage is used to avoid persistent lock state across transactions
  • A test simulates a reentrant token contract and confirms the guard fires
  • Lock coverage extends to cancel_invoice and any other fund-moving methods
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptssecuritySecurity hardening and access control

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions