Repository navigation
feat(gateway): let CVMs prove possession of their WireGuard key - #1615
Merged
Merged
Conversation
kvinwang
enabled auto-merge
November 18, 2026 09:11
kvinwang
disabled auto-merge
November 18, 2026 09:28
kvinwang
enabled auto-merge
November 18, 2026 10:53
kvinwang
added a commit
that referenced
this pull request
Nov 18, 2026
Import follows #1604: a record carrying any replicated gateway key, or the judging node's own, is rejected as LostConflict on every node. Nodes with equal KV contents now agree once their own keys have replicated; the window before that is kept as a counterexample. Key squatting is added: a counterexample without proof of possession, and stable key binding under the hypothesis that every record was registered by its key's holder (#1615, modeled abstractly). IpAlloc follows #1605: release_ip frees an address only when no other instance holds it. Registration, rebuild, forget and KV reload are modeled, and alloc_ip never reissues a live address, including one a conflict loser shares during its grace period. PoolsClear stays an assumption; #1606 only warns. Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
feat/gateway-wg-key-proof
branch
from
November 18, 2026 11:34
70e6677 to
36a783b
Compare
kvinwang
disabled auto-merge
November 18, 2026 11:34
RegisterCvm took the CVM's WireGuard public key on trust. A CVM that learned another CVM's key could register with it while the victim's record was recycled; when the victim returned, its newer record lost the oldest-wins key conflict on every node and stayed out of rotation, its own handshakes (credited by key) keeping the squatter alive. The gateway now reports its WireGuard key in Info, and a CVM attaches a proof: HMAC-SHA256 keyed by HKDF(X25519(client_sk, gateway_pk)) over the client key, gateway key, app id and instance id from its RA-TLS cert. Low-order keys are rejected. A CVM that cannot build a proof registers as before. Whether a missing or invalid proof is refused is one cluster-wide switch in the replicated KV (global/wg_key_proof_config), set with the admin SetWgKeyProofConfig RPC and read per registration. It is off until set; off, bad proofs are only logged so operators can tell when the fleet is ready. An unreadable record fails closed. Only the registering node verifies; replicated records are unchanged, so records written before the switch was turned on are not re-checked. Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
force-pushed
the
feat/gateway-wg-key-proof
branch
from
November 18, 2026 11:34
36a783b to
6d50929
Compare
kvinwang
enabled auto-merge
November 18, 2026 11:34
kvinwang
added a commit
that referenced
this pull request
Nov 18, 2026
Import follows #1604: a record carrying any replicated gateway key, or the judging node's own, is rejected as LostConflict on every node. Nodes with equal KV contents now agree once their own keys have replicated; the window before that is kept as a counterexample. Key squatting is added: a counterexample without proof of possession, and stable key binding under the hypothesis that every record was registered by its key's holder (#1615, modeled abstractly). IpAlloc follows #1605: release_ip frees an address only when no other instance holds it. Registration, rebuild, forget and KV reload are modeled, and alloc_ip never reissues a live address, including one a conflict loser shares during its grace period. PoolsClear stays an assumption; #1606 only warns. Signed-off-by: Kevin Wang <wy721@qq.com>
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.
RegisterCvmtook the CVM's WireGuard public key on trust. A CVM that learned another CVM's public key could register with it while the victim's record was recycled; when the victim returned, its newer record lost the key conflict on every node and stayed out of rotation (its own handshakes, credited by key, kept the squatter alive). It could not read the victim's traffic, but it could keep it offline.InfoResponse.wg_public_keyreturns the node's WireGuard key;RegisterCvmRequest.wg_key_proofcarries{gateway_public_key, mac}.dstack-gateway-rpc::wg_key_proof.Infobefore registering and attaches a proof when the gateway returns a key; otherwise registers as before.global/wg_key_proof_config), read withGetWgKeyProofConfigand set at runtime withSetWgKeyProofConfig(audited), read per registration. Off until set. Off: an invalid or missing proof is accepted with a warning/debug log, so the logs show when the fleet is ready. On: a missing or invalid proof is refused. An unreadable record fails closed (proofs required) until an operator overwrites it. Only the registering node verifies; replicated records are unchanged.Compatibility: old CVMs and old gateways keep working; registration costs one extra
Infocall. The attack is closed only once every node runs this and the policy requires proofs. IfInfoandRegisterCvmland on different nodes (a per-request load balancer), the proof names the wrong key: warned when off, refused when on (seedocs/dstack-gateway.md).