Skip to content

[Contract] Bounds-check arbiter awards #29

Open

Description

@Gbangbolaoluwagbemiga

Problem

arbiter_award_freelancer(escrow_id, arbiter, freelancer_amount) in refund_system.rs takes an
arbitrary freelancer_amount. If it exceeds the remaining escrowed balance, the contract could
attempt to pay out more than it holds (or drain funds reserved for other escrows).

What needs to be done

  • Compute the remaining unreleased amount for the escrow
  • Reject when freelancer_amount > remaining with a typed error (e.g. SecureFlowError::InsufficientWithdrawable)
  • Reject negative / zero amounts
  • Use checked arithmetic for the client-remainder calculation

Acceptance criteria

  • freelancer_amount > remaining → Err(...), no transfer occurs
  • freelancer_amount == remaining (boundary) succeeds, client gets 0
  • Adversarial tests for overflow and zero/negative inputs

Relevant files

contracts/secureflow/src/refund_system.rs (arbiter_award_freelancer, do_transfer)

Activity

  1. changed the title [-]Bounds-check arbiter awards[/-] [+][Contract] Bounds-check arbiter awards[/+] on Jun 17, 2026
  2. shobhamerabacha-star commented on Oct 7, 2026

    @shobhamerabacha-star

    Hello team,

    I looked into [Contract] Bounds-check arbiter awards and have an implementation approach ready.

    Plan:

    1. Audit storage layout and state invariants ensuring strict auth guards.
    2. Implement deterministic state transitions with safe checked arithmetic.
    3. Add hermetic unit and regression tests covering authorized, unauthorized, and boundary edge cases.
    4. Profile instruction and CPU/gas limits under Soroban host environment.

    Could you please assign this issue to me? Looking forward to delivering a clean PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditRequired before / part of a security auditsecuritySecurity-sensitive work

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions