Skip to content

Bind trust to registry-confirmed keys; require signed accept, reject and revoke - #54

Merged
TeoSlayer merged 2 commits into
mainfrom
fix/autoapprove-binding
Nov 9, 2026
Merged

TeoSlayer merged 2 commits into
mainfrom
fix/autoapprove-binding

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Trust is bound only to keys the registry confirmed, and every accept, reject and revoke must be signed.

  • IsTrustedWithKey(id, "") no longer passes a record bound to a key; IsTrustedByNodeID (and IsTrusted) answer by node ID on purpose.
  • Every automatic-trust rule, trust-auto-approve included, needs the registry to confirm the sender's key. Relayed requests look the key up first and bind the record to it. A request the registry cannot confirm waits in the pending queue.
  • A key a peer presents no longer binds, rebinds or drops a record by itself; an unbound record is bound by a registry lookup (at most one per node per 30 s).
  • Pending requests record whether their key was confirmed (key_confirmed, optional in snapshots, so old snapshots load).
  • Accept, reject and revoke messages without a key or signature are refused. Every released daemon sends them signed.

Behaviour change: a trust-auto-approve or relayed request that the registry cannot confirm now waits for the operator.

Teo Calin added 2 commits November 8, 2026 16:45
…a bound record

IsTrustedWithKey(id, "") answered by node ID alone, so a caller with no
key in scope passed a record bound to a key. It now reports false for a
bound record. An unbound record is still trusted by node ID, which is all
it grants. Callers that mean the node ID alone have IsTrustedByNodeID
(IsTrusted is the same, under the name daemonapi.HandshakeService uses).

Automatic trust needed the registry's confirmation on some rules and not
others:
- Direct requests: mutual, same-network and trusted-agent required
  registryBound; trust-auto-approve did not, so with the registry lookup
  failing, any sender could claim any node ID with its own key pair and
  be trusted under it. It now requires registryBound; an unconfirmed
  request waits in the pending queue.
- Relayed requests: no rule checked a key. Each now needs the registry to
  list a key for the sender (looked up before the rules run) and binds
  the record to it. With no key, the request waits for the operator. The
  allowlist is asked with that key, so a pinned entry can match over the
  relay, where it was asked with "" and never could.

A key a peer merely presents no longer binds or drops a record:
- IsTrustedWithKey no longer adopts the first key presented into an
  unbound record. It starts a registry lookup (backfillPeerKey) instead,
  at most one per node per 30 s, so a per-packet check cannot flood the
  registry.
- A request or accept whose key the registry did not confirm leaves an
  existing record alone: an unbound one is bound by a registry lookup; a
  record bound to another key is kept and the message ignored. Before, a
  request under another key during a registry outage dropped the record,
  and one for an unbound record bound it to the sender's key.
- A new record from an unconfirmed accept is unbound until the registry
  binds it.
- Pending requests record whether the registry confirmed their key
  (KeyConfirmed, persisted as key_confirmed). Approving one binds its key
  only then, and otherwise the registry's key. An unconfirmed request no
  longer replaces a confirmed pending one under another key.

Behaviour changes: a trust-auto-approve or relayed request that the
registry cannot confirm (registry down, or a node with no key, of which
the live registry lists none) now waits for the operator instead of being
trusted. Snapshots stay compatible both ways: key_confirmed is optional,
and older pending entries load as unconfirmed, so approving them binds
the registry's key.
processMessage checked a signature only when a message carried
PublicKey, and refused a keyless message only for requests. An accept,
reject or revoke without a key went through on the transport's source
node ID alone, which nothing proves in plaintext mode.

Every daemon release sends both: from v1.1.0 (the first tag), through
the in-tree pkg/daemon and plugins/handshake code and every handshake
module release (v0.1.0 to v0.3.3), sendAccept, RejectHandshake and
RevokeTrust set PublicKey to the daemon's key and sendMessage signs every
message, and every daemon generates its identity at start. libpilot
embeds the same plugin. So a message of any type without a key or a
signature is now refused.

Without the registry's answer, a signature checked against the key the
message brings only shows the sender holds some key. For an accept,
reject or revoke from a peer whose trust record is bound to a key, that
key now stands in for the registry: the message must carry and be signed
by it.
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer
TeoSlayer merged commit 2fe556b into main Nov 9, 2026
4 checks passed
@TeoSlayer
TeoSlayer deleted the fix/autoapprove-binding branch November 9, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant