Skip to content

Digest replay protection in @suimpp/mpp server verification #2

@funkiirabu

Description

@funkiirabu

Problem

The @suimpp/mpp server verify() callback checks the transaction on-chain (succeeded, right recipient, right amount) but does not track used digests. The same TX digest could be presented against multiple challenges — paying once but consuming multiple API calls.

Context

mppx already solves this for the tempo method with assertHashUnused / markHashUsed + a store interface. The same pattern should be added to the sui method.

Proposed Solution

Add digest tracking to @suimpp/mpp/server:

  1. Add an optional store interface to SuiServerOptions:

    interface DigestStore {
      has(digest: string): Promise<boolean>;
      set(digest: string): Promise<void>;
    }
  2. In verify(), before returning the receipt:

    • Call store.has(digest) — if true, throw "Digest already used"
    • Call store.set(digest) — mark as consumed
  3. Provide a default in-memory store (Map with TTL) for single-instance deployments

  4. Allow custom stores (Redis, DB) for multi-instance / serverless deployments

References

  • mppx tempo implementation: assertHashUnused / markHashUsed pattern
  • Current verify: packages/mpp/src/server.ts lines 39-119

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething 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