Repository navigation
Bind trust to registry-confirmed keys; require signed accept, reject and revoke - #54
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(andIsTrusted) answer by node ID on purpose.trust-auto-approveincluded, 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.key_confirmed, optional in snapshots, so old snapshots load).Behaviour change: a
trust-auto-approveor relayed request that the registry cannot confirm now waits for the operator.