You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Security] Internal security audit of Soroban escrow contract #18
Scope reviewed: contracts/secureflow/src on main at 5a52f4a. This was a static review; I did not run local tooling or deploy the contract.
✅ Passes
Core role authorization is present on the sensitive user paths I checked: create_escrow requires depositor auth, work submission/start requires beneficiary auth, milestone approval/rejection/refund/deadline extension require depositor auth, and arbiter resolution requires an authorized arbiter.
Milestone/arbiter vector sizes are bounded in create_escrow: mismatched milestone arrays, more than 20 milestones, more than 5 arbiters, and
equired_confirmations > arbiters.len() are rejected.
Token whitelisting is enforced before escrow funding, and owner-only admin paths call
equire_owner.
⚠� Findings
High: native XLM emergency refunds mark funds released without transferring them
emergency_refund_after_deadline updates the escrow status to Expired and decrements EscrowedAmount, but its native-XLM branch is empty:
contracts/secureflow/src/refund_system.rs:103-117 reduces escrow accounting by
efund_amount.
contracts/secureflow/src/refund_system.rs:119-125 transfers only if escrow.token is Some; the None branch contains only // Native XLM refund.
contracts/secureflow/src/refund_system.rs:127 saves the escrow.
Impact: for native-XLM escrows that reach the emergency path, the contract records the escrow as expired/released from escrow accounting, but the depositor receives no refund. The funds remain in the contract while the normal escrow state now says the amount is no longer escrowed, which can make user recovery and later accounting unsafe.
Suggested fix: route this branch through the same native SAC transfer helper used by
efund_escrow / do_transfer, and update accounting/state only after the transfer succeeds. Add a test for oken == None on emergency_refund_after_deadline that verifies both recipient balance and escrow accounting.
create_escrow bounds the milestone count but does not validate that the escrow economics are internally consistent:
It does not reject otal_amount <= 0 before using otal_amount for fee calculation, funding transfer, and escrowed accounting (escrow_management.rs:58, 74, 81-85, 98).
It allows zero milestones because only milestone_amounts.len() > 20 is checked (escrow_management.rs:40-42).
It does not reject zero/negative milestone amounts before saving each milestone (escrow_management.rs:124-142).
It does not require sum(milestone_amounts) == total_amount.
Impact: an escrow can be created with no payable path, with milestone totals lower/higher than deposited funds, or with invalid milestone values. Later, �pprove_milestone trusts the saved milestone amount, increments paid_amount, decrements escrowed accounting, and transfers that amount (work_lifecycle.rs:139-183). This can lock residual funds when milestone totals are below otal_amount, prevent normal completion when totals exceed it, or make accounting depend on token behavior for invalid amounts.
Suggested fix: in create_escrow, require otal_amount > 0, at least one milestone, every milestone amount > 0, and checked sum equality with otal_amount before any token transfer or escrow ID increment. Add negative/zero/empty/mismatched-sum tests.
Medium: several required arithmetic operations are unchecked
The issue asks to verify overflow/underflow protection, but many state-critical operations use direct +, -, or *:
escrow_core.rs:30: current_id + 1 for the next escrow ID.
escrow_core.rs:102: (amount * fee_bp as i128) / 10000 for platform fee calculation.
escrow_management.rs:62: current_ledger + duration / 5 for deadline calculation.
Impact: with enough accumulated state, or with malformed values accepted at creation time, these operations can panic or wrap depending on build/runtime behavior, causing denial of service or incorrect escrow accounting. Even if Soroban traps on overflow in the current toolchain, this still means user actions can hard-fail instead of returning contract errors.
Suggested fix: replace these with checked_add, checked_sub, and checked_mul, mapping failure to SecureFlowError::InvalidAmount or a dedicated overflow error. For escrowed-accounting subtraction, also require current_escrowed >= amount/refund_amount/available before writing storage.
Notes
I did not find missing
equire_auth on the primary listed flows during this pass. The strongest issue is the emergency native refund path because the state/accounting mutation is present while the transfer is absent.
I would like to take on and implement this issue: [Security] Internal security audit of Soroban escrow contract.
Technical Implementation Roadmap:
Formal Soroban Invariant Design: Audit storage layout (Instance, Persistent, Temporary) with strict TTL management and explicit require_auth guards.
Core Rust WASM Implementation: Implement deterministic state transition handlers eliminating arithmetic overflow risks using checked/saturating math.
Hermetic Testing Suite: Build comprehensive test cases in tests/ asserting authorized vs unauthorized invocations, mock auth environments, and edge value bounds.
Gas & Footprint Optimization: Profile CPU/memory instruction budgets under Soroban host environment to ensure optimal runtime efficiency.
I have worked extensively on similar architectures and can deliver this cleanly within 24 hours. Please assign to me!
Activity
silentgeckoaudit3801 commentedon Jul 13, 2026
Security audit report
Scope reviewed: contracts/secureflow/src on main at 5a52f4a. This was a static review; I did not run local tooling or deploy the contract.
✅ Passes
equired_confirmations > arbiters.len() are rejected.
equire_owner.
⚠� Findings
High: native XLM emergency refunds mark funds released without transferring them
emergency_refund_after_deadline updates the escrow status to Expired and decrements EscrowedAmount, but its native-XLM branch is empty:
efund_amount.
Impact: for native-XLM escrows that reach the emergency path, the contract records the escrow as expired/released from escrow accounting, but the depositor receives no refund. The funds remain in the contract while the normal escrow state now says the amount is no longer escrowed, which can make user recovery and later accounting unsafe.
Suggested fix: route this branch through the same native SAC transfer helper used by
efund_escrow / do_transfer, and update accounting/state only after the transfer succeeds. Add a test for oken == None on emergency_refund_after_deadline that verifies both recipient balance and escrow accounting.
Medium: escrow creation accepts inconsistent milestone accounting
create_escrow bounds the milestone count but does not validate that the escrow economics are internally consistent:
Impact: an escrow can be created with no payable path, with milestone totals lower/higher than deposited funds, or with invalid milestone values. Later, �pprove_milestone trusts the saved milestone amount, increments paid_amount, decrements escrowed accounting, and transfers that amount (work_lifecycle.rs:139-183). This can lock residual funds when milestone totals are below otal_amount, prevent normal completion when totals exceed it, or make accounting depend on token behavior for invalid amounts.
Suggested fix: in create_escrow, require otal_amount > 0, at least one milestone, every milestone amount > 0, and checked sum equality with otal_amount before any token transfer or escrow ID increment. Add negative/zero/empty/mismatched-sum tests.
Medium: several required arithmetic operations are unchecked
The issue asks to verify overflow/underflow protection, but many state-critical operations use direct +, -, or *:
efund_system.rs:31, 52, 87, 95, 116, 151, 263, 323, 339, 347: refund amount, escrowed accounting, deadline delay, deadline extension, arbiter award accounting.
atings.rs:86-87 and 194: rating totals/counts.
Impact: with enough accumulated state, or with malformed values accepted at creation time, these operations can panic or wrap depending on build/runtime behavior, causing denial of service or incorrect escrow accounting. Even if Soroban traps on overflow in the current toolchain, this still means user actions can hard-fail instead of returning contract errors.
Suggested fix: replace these with checked_add, checked_sub, and checked_mul, mapping failure to SecureFlowError::InvalidAmount or a dedicated overflow error. For escrowed-accounting subtraction, also require current_escrowed >= amount/refund_amount/available before writing storage.
Notes
I did not find missing
equire_auth on the primary listed flows during this pass. The strongest issue is the emergency native refund path because the state/accounting mutation is present while the transfer is absent.
guptakumarranjeet150 commentedon Oct 2, 2026
Hello maintainers,
I would like to take on and implement this issue:
[Security] Internal security audit of Soroban escrow contract.Technical Implementation Roadmap:
Instance,Persistent,Temporary) with strict TTL management and explicitrequire_authguards.tests/asserting authorized vs unauthorized invocations, mock auth environments, and edge value bounds.I have worked extensively on similar architectures and can deliver this cleanly within 24 hours. Please assign to me!