Skip to content

fix(node): clamp a presented capability to the signer's on-chain registration #2265

Closed

Description

@alpergundogdu

Problem

A node holds the cap and expiry of the capability the client presents, not the terms registered on-chain. On-chain registration is write-once (PaymentPool._registerCapability returns early once authorized[poolId][signer] is set), so a second owner-signed capability for an already-registered signer is ignored at redemption.

Evidence:

  • ADR 003 § Mid-stream signer cap re-check: held_cap is "the cap the node holds on the lane from admission", taken from the presented capability.
  • crates/node/src/payment_settlement.rs:1660 persists registered_until from reg.expiry, the presented capability's expiry, after a registration lands, even when the on-chain registration was a no-op.
  • No call site in crates/node reads getAuthorization / getAuthorizations.

Attack

The pool owner (the payer) is the attacker:

  1. Register signer S with a small/short capability by getting one redemption landed.
  2. Sign a second capability for S with a larger cap or later expiry and pull from other nodes.
  3. Those nodes admit and serve under the second capability's terms. On-chain, vouchers past the first capability's cap or expiry redeem to 0.

The loss scales with blob size. This is traced from code, not yet reproduced.

Fix

The node protects itself (no contract change; capability renewal stays out, signers rotate keys):

  1. Failing test first (e2e or settlement-level): register S with capability A, present capability B (higher cap, later expiry) for S at another node, and show the node serves past A's terms and the redemption pays 0 beyond them.
  2. Admission: for a (pool, signer) the node has not seen registered, read getAuthorization once. If registered, hold min(presented, on-chain) for cap and expiry; refuse if the clamped terms cannot cover a serve floor. Cache the registered terms per (pool, signer) for the process lifetime and persist them with the lane: write-once registration means they never change.
  3. Redemption: at payment_settlement.rs:1660, persist the expiry the chain registered (from the read or the landed registration's event), not the presented reg.expiry.
  4. Update ADR 003 (Capability delegation, mid-stream signer cap re-check) and ADR 005 if the admit path changes, in present-tense STE.

Open decision

Residual race: two different capabilities for a signer that is not yet registered. The first to land wins, and a node holding the other one can over-serve until its own first redemption reveals the registered terms. Options: accept this bounded window, or redeem early for a signer the node has not yet seen registered. Decide before step 2 lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions