fix: use Protocol Context encryption for all records so peers can decrypt (#87, #88)#89
Merged
Merged
Conversation
…rypt (#87, #88) The anchor was writing its own node, nodeInfo, and endpoint records with Protocol Path encryption (derived from the anchor's root key). Peers only have the shared context key and cannot decrypt Protocol Path records from a different root key. This meant peers could not read the anchor's mesh IP or endpoints, preventing WireGuard tunnels from forming. Fix: - network create: write anchor's node and nodeInfo with context encryption - peer add: write peer's node record with context encryption - meshd up (anchor): enable context encryption for endpoint writes - meshd up (anchor): pass UseContextEncryption to engine config so STUN-discovered endpoint updates also use context encryption Also skip undecryptable peers in buildMapResponse (#88). When a node record cannot be decrypted, the resulting Node has no mesh IP and no endpoints. These ghost peers pollute the WireGuard network map. Now they are filtered out of the map while still being tracked in the nodes map for auto key delivery purposes. Fixes #87 Fixes #88
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.
Summary
Two critical fixes that unblock the real-world two-machine E2E flow.
Problem
When tracing the exact user scenario (
meshd up --createon Machine A,meshd up --anchoron Machine B), we discovered that no WireGuard tunnel can form because:The anchor encrypts its own records with Protocol Path encryption (derived from the anchor's root key). Peers only have the shared context key. They cannot decrypt the anchor's node, nodeInfo, or endpoint records, so they cannot discover the anchor's mesh IP or network endpoints.
Undecryptable nodes pollute the network map. When a node record can't be decrypted,
nodeRecordToNodeproduces aNodewith no mesh IP, no addresses, and no endpoints. WireGuard gets a peer entry it can't route traffic to.Fix
#87: Protocol Context encryption everywhere
network create->RegisterNode(anchor self)network create->WriteNodeInfo(anchor self)peer add->RegisterNode(peer node)meshd up(anchor) -> endpoint writesuseContextEncryption = false)useContextEncryption = true)meshd up(anchor) -> engine configUseContextEncryption: falseUseContextEncryption: trueThe anchor derives the context key from its root key via HKDF (this already works in
EncryptionKeyManager.resolveContextPrivateKey). No new key delivery or storage needed.#88: Skip ghost peers in network map
In
buildMapResponse, peers with no valid mesh IP are now skipped. They remain inc.nodesfor auto key delivery tracking but are not injected into the WireGuard network map.Verification
go build ./...-- zero errorsgo vet ./...-- zero warningsgo test ./... -count=1 -race-- all tests passFixes #87
Fixes #88