Skip to content

Family Wallet: i128 overflow safety audit for spending limits and precision tracker arithmetic #642

@Baskarayelu

Description

@Baskarayelu

Description

FamilyWallet performs i128 arithmetic across check_spending_limit, validate_precision_spending, update_spending_limit, and the SPND_TRK tracker accumulation. Although the release profile sets overflow-checks = true, panics on overflow are a denial-of-service vector and silently saturating logic could mis-account spending. Every add/subtract on amounts and accumulated spend must use checked_* operations with explicit Error returns rather than relying on panic-abort.

Requirements and context

  • Secure: Replace raw +/- on amounts with checked_add/checked_sub returning a defined Error variant.
  • Tested: Tests pushing values near i128::MAX and asserting graceful error rather than panic.
  • Documented: Add an overflow-safety note in docs/fw-overflow-safety.md.
  • Reference SpendingTracker, PrecisionSpendingLimit, SPND_TRK, PREC_LIM, check_spending_limit, validate_precision_spending.

Suggested execution

Create branch feature/fw-overflow-safety.

  • Modify arithmetic in family_wallet/src/lib.rs to use checked operations.
  • Write tests in family_wallet/src/test.rs for near-max amounts.
  • Add docs docs/fw-overflow-safety.md.
  • Add /// comments on checked helpers.
  • Validate no arithmetic panics on hostile inputs.

Test and commit

  • Run cargo test -p family_wallet.
  • Cover edge cases: amount overflow, accumulated-spend overflow, negative amount.
  • Include test output and security notes.

Example commit message

feat: use checked i128 arithmetic across family wallet spending paths

Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programsecuritySecurity hardening and auditssmart-contractSoroban/Rust smart contract worksorobanStellar Soroban specific

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions