Description
The cancel_stream function currently transfers the remaining token balance back to the sender before fully updating the stream's active state in storage. While Soroban has some mitigations, if the token contract allows for callbacks, this could potentially be exploited to reenter the contract.
Suggested Fix
Apply the Checks-Effects-Interactions pattern strictly:
- Load the stream state and verify the caller is authorized (Checks).
- Update the stream state in storage to
Canceled and zero out the pending balances (Effects).
- Perform the token transfers to the sender and recipient (Interactions).
Optionally, add a standard reentrancy guard if complex callbacks are expected.
Description
The
cancel_streamfunction currently transfers the remaining token balance back to the sender before fully updating the stream's active state in storage. While Soroban has some mitigations, if the token contract allows for callbacks, this could potentially be exploited to reenter the contract.Suggested Fix
Apply the Checks-Effects-Interactions pattern strictly:
Canceledand zero out the pending balances (Effects).Optionally, add a standard reentrancy guard if complex callbacks are expected.