Skip to content

Audit unwrap() and panic sites in the explorer contract for untrusted-input paths #2

Description

@priscaenoch

Problem

explorer/src/lib.rs contains ~20 unwrap() / panic! / todo! sites. In a Soroban contract, an unhandled panic aborts the invocation and can be triggered by malformed or unexpected input, which is a poor and potentially exploitable failure mode. State-reading getters that unwrap() on absent storage (for example an uninitialised admin) will panic rather than return a typed error.

What needs to be done

  • Enumerate every unwrap()/panic!/todo! in explorer/src/lib.rs.
  • For each, determine whether it can be reached by untrusted input or by calling a function before init.
  • Replace reachable ones with typed Error returns (Result<_, Error>) or panic_with_error! using the existing error enum, so failures are explicit and typed.
  • Leave only invariant-guaranteed unwraps, each with a justifying comment.

Files

  • explorer/src/lib.rs

Acceptance deliverables

  • No unwrap()/panic! reachable from untrusted input without a typed error or a documented invariant.
  • Calling state getters before initialisation returns a typed error rather than an untyped panic.

Tests to pass

  • Tests asserting typed errors for pre-init calls and for invalid inputs on the audited functions.
  • cargo test passes.

Activity

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

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignbugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions