Description
CalloraVault::withdraw_to lets the owner send tracked USDC to an arbitrary to address and is intentionally allowed while paused (emergency recovery), but it performs no recipient validation and the pause-allowed behavior is undocumented at the function level. Add recipient guards and explicit /// documentation of the emergency-withdrawal policy.
Requirements and Context
- Reject
to == env.current_contract_address() (sending back into the vault) and optionally to == usdc_token.
- Document at the function level that
withdraw/withdraw_to are permitted while paused for recovery, matching the module-level note.
- Confirm CEI ordering relative to the token transfer.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b bug/vault-withdraw-to-validation
- Implement changes
contracts/vault/src/lib.rs — recipient guard + /// pause policy
VAULT_WITHDRAW_COMPLIANCE.md — align documented behavior
- Test and commit
cargo test -p callora-vault
- Test withdraw_to-while-paused succeeds; self-address rejected
- Include test output and notes in the PR
Example commit message
fix: validate withdraw_to recipient and document pause policy
Acceptance Criteria
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
Description
CalloraVault::withdraw_tolets the owner send tracked USDC to an arbitrarytoaddress and is intentionally allowed while paused (emergency recovery), but it performs no recipient validation and the pause-allowed behavior is undocumented at the function level. Add recipient guards and explicit///documentation of the emergency-withdrawal policy.Requirements and Context
to == env.current_contract_address()(sending back into the vault) and optionallyto == usdc_token.withdraw/withdraw_toare permitted while paused for recovery, matching the module-level note.Suggested Execution
contracts/vault/src/lib.rs— recipient guard +///pause policyVAULT_WITHDRAW_COMPLIANCE.md— align documented behaviorcargo test -p callora-vaultExample commit message
Acceptance Criteria
Guidelines
.rsundercontracts/vault/src/,cargo test,///docs, minimum 95% line coverage, nounwrap()in prod paths