Skip to content

security(bus): make authenticated peer provenance mandatory at the Transport/Inbound seam #79

Description

@hartsock

Problem

agent_mesh_bus::Inbound carries a signed envelope and an opaque reply route, but no evidence identifying the peer authenticated by the transport session. The iroh implementation currently performs signer/session matching inside accept_conn, while the shared Transport seam does not require that check and the in-memory transport can bypass envelope verification entirely.

That makes transport authentication an implementation convention instead of a bus invariant: a new transport can hand an unbound envelope to the inbox, which then reconstructs RequestContext from the envelope alone.

Found while reviewing #77; this is the transport-neutral residual from #75.

Scope

  • Add a typed authenticated-peer/delivery-provenance value to Inbound.
  • Verify every envelope at the common bus admission boundary before replay state or dispatch is mutated.
  • For direct delivery, require the envelope signer and user root to match the transport-authenticated peer and the local same-user policy.
  • Represent missing binding explicitly and reject it by default.
  • Keep carrier identity distinct from original signer identity so a future authorized-relay design cannot accidentally conflate them.
  • Move the iroh session check into this shared contract; make the in-memory transport produce honest peer evidence rather than bypassing verification.

Acceptance

  • Transport::recv cannot deliver a direct envelope without typed authenticated-peer evidence.
  • The common receive boundary rejects unbound, signer-mismatched, stranger-rooted, bad-signature, and CID-mismatched envelopes before replay/sequence state changes.
  • Iroh binds conn.remote_id() to the handshake certificate and supplies the resulting peer evidence to the bus.
  • Existing request/reply behavior remains green for same-user, correctly bound peers.
  • Real-boundary negative tests prove a valid envelope relayed over another peer's session is rejected.
  • In-memory tests cannot pass while skipping SignedEnvelope::verify().
  • just check and just cov-ci pass.

Related

Out of scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions