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
Description
Token transfer callbacks in Soroban can re-enter the contract if the token contract is malicious or misconfigured. The
release_paymentandcancel_invoicefunctions must be protected by a reentrancy lock to prevent state corruption from recursive calls.Technical Context
Store a
ReentrancyLockboolean instorage::temporaryincontracts/split/src/lib.rs. Introduce awith_reentrancy_guardclosure wrapper that sets the flag on entry, runs the body, then clears it. Callenv.storage().temporary()so the lock is automatically dropped at transaction boundary. ReturnReentrantCallerror on attempted reentry.Acceptance Criteria
release_paymentwithin the same transaction returnReentrantCallcancel_invoiceand any other fund-moving methods