Skip to content

Vault: add reentrancy-equivalent test using a malicious mock token on deduct #344

@greatest0fallt1me

Description

@greatest0fallt1me

Description

The vault performs external USDC transfer calls in deduct, batch_deduct, withdraw, and distribute. There is no test exercising a hostile token contract that attempts to re-enter the vault during the transfer. Add a malicious mock token and assert that state effects (meta.balance) cannot be corrupted by re-entry.

Requirements and Context

  • Implement a mock token whose transfer calls back into CalloraVault::deduct.
  • Assert the re-entrant call either fails (auth/pause) or cannot double-spend balance.
  • Cover both single deduct and batch_deduct.
  • 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/vault-reentrancy-mock-token
  2. Implement changes
    • contracts/vault/src/test.rs — malicious token mock + re-entry tests
  3. Test and commit
    • cargo test -p callora-vault
    • Assert no balance corruption and deterministic revert
    • Include test output and notes in the PR

Example commit message

test: add reentrancy-equivalent mock token tests to vault

Acceptance Criteria

  • Malicious mock token re-enters during transfer
  • Balance cannot be double-spent
  • Both deduct and batch_deduct covered
  • Tests pass deterministically

Guidelines

  • .rs under contracts/vault/src/, cargo test, /// docs, minimum 95% line coverage, no unwrap() in prod paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programauditSecurity audit/reviewsecuritySecurity hardeningsmart-contractSoroban smart-contract worktestingTests and coverage

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions