Skip to content

Harden stealth deposit/withdraw race conditions and balance invariants #34

Description

@grantfox-oss

Stealth entry handling can race with direct deposits or withdrawals, allowing balance mismatches or stealth entries to persist after a withdrawal due to inconsistent storage ordering.

Affected areas: app/contract/contracts/Folder/src/stealth.rs, app/contract/contracts/Folder/src/storage.rs, app/contract/contracts/Folder/src/lib.rs, app/contract/contracts/Folder/src/test.rs.

Implementation scope:

  • Add stronger ordering and locking invariants around stealth deposit and withdrawal flows.
  • Validate stealth entry balances before and after every state transition.
  • Add explicit cleanup for empty stealth entries and orphaned balances.
  • Add regression tests for concurrent stealth deposit/withdrawal and direct deposit collisions.

Acceptance criteria:

  • Stealth withdrawal can never leave a stale stealth entry with non-zero balance.
  • Concurrent operations preserve the invariant that total deposited value equals escrow plus stealth state.
  • Tests cover identical and overlapping stealth operations.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions