Skip to content

Implement reentrancy guards utilizing transient storage for cross-contract fractional token swaps #476

Description

@Damola-Sodiq

Description

Secure the fractional token exchange functions against malicious reentrancy callbacks by leveraging ephemeral transient storage locks.

Architecture & Context

When the smart contract invokes an external token contract to perform a transfer, malicious tokens can execute a callback into the original vault before the state balances are updated. Using transient storage (state that clears automatically at the end of the transaction) provides an ultra-cheap, bulletproof mutex lock.

Technical Requirements

  • Implement a non_reentrant modifier pattern in the Soroban SDK utilizing temporary storage keys.
  • Wrap all state-mutating mint, burn, and swap functions within this lock.
  • Ensure the lock is flawlessly released even if an internal sub-routine fails gracefully.

Acceptance Criteria

  • Cross-contract reentrancy attempts immediately panic and revert the state.
  • Normal, non-recursive execution flows flawlessly.
  • Transient storage rent costs are mathematically negligible.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions