Skip to content

[Gap]: Store: a transfer recipient directory can't be unique across owners, so a lookup by name is spoofable #953

Closed

Description

@jimhoyd

From the third agent workflow trial (credits wallet task: pay by recipient lookup). Follows #929 item 3.

What you were trying to do

Pay another user by looking up their wallet. Per #929 this uses a projected readers directory: readers: {mount: /api/directory, properties: [name]}, with filterable: [name], then POST /api/wallets/transfers/pay to the id found.

Where it broke down

The directory answers the lookup, but a name identifies nobody. Wallet names are chosen by each owner and can't be unique: key is "Not allowed with ownership: owner", and there is no other uniqueness constraint. Another user can open a wallet with the same name and appear in the same lookup:

  • bob opens wallet bob; GET /api/directory?name=bob answers total: 1.
  • mallory opens a wallet also named bob (201); the same lookup now answers total: 2. A payer can't tell which one is bob's. showOwner would add _owner, but with Better Auth that is an opaque user id the payer doesn't know.

So "pay by recipient lookup" is spoofable. The safe version needs a handle that is unique across owners, or bound to the owner's identity, which can't be declared on an owned collection.

Expected, one of:

  • a unique property on an owned collection (unique across owners, 409 on a duplicate), for example unique: [handle];
  • or a transfer addressed to an owner's verified identifier (for example the recipient's email via the auth extension) instead of a record id.

Code or YAML you had to write by hand

wallets:
  mount: /api/wallets
  ownership: owner
  idempotency: {maxKeys: 1000}
  schema:
    type: object
    additionalProperties: false
    required: [name, balance]
    properties:
      name: {type: string, minLength: 1, maxLength: 40}
      balance: {type: integer}
  defaults: {balance: 0}
  readOnlyProperties: [balance]
  filterable: [name]
  readers: {mount: /api/directory, properties: [name]}
  transfers:
    pay: {amount: balance}
    issue: {amount: balance, min: -1000000, members: issuers}

These steps pass. They record the observed behavior:

{"path": "/api/directory?name=bob", "status": 200, "expectJson": {"/items/0/id": "{{bob}}", "/items/0/name": "bob", "/total": 1}},
…sign in as mallory…
{"path": "/api/wallets", "method": "POST", "headers": {"origin": "{{origin}}", "content-type": "application/json"}, "body": "{\"name\":\"bob\"}", "status": 201, "expectJson": {"/name": "bob"}},
{"path": "/api/directory?name=bob", "status": 200, "expectJson": {"/total": 2}}

npm test → {"total":32,"failed":0}.

What you could not verify

Whether an operator-assigned name (a readOnlyProperties name set by a transition) was intended as the answer. It can't work: transitions set constants only.

Runtime revision and environment

main f850492a (0.6.5), packed install, macOS, Node 26.10.0.

Activity

  1. added
    ai-first
    on Sep 29, 2026
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

    ai-first

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions