Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
controlplane: proof of possession on /register and /routers/lease (audit H1, H6)
Antonio Ojeafe9a110bdcb3
diff --git a/api/network.go b/api/network.goindex f073f5cb..38ce4660 100644--- a/api/network.go+++ b/api/network.go@@ -103,6 +103,22 @@ func RefreshChallenge(peerID string, ts int64) []byte {return []byte("sam:refresh:" + peerID + ":" + strconv.FormatInt(ts, 10))}+// RegisterChallenge is the payload an OIDC enrollee signs to prove possession+// of EnrollRequest.public_key at POST /register, carried in that message's+// timestamp/challenge_signature fields. The JWT says who is asking; this says+// they hold the key they are binding.+func RegisterChallenge(peerID string, ts int64) []byte {+ return []byte("sam:register:" + peerID + ":" + strconv.FormatInt(ts, 10))+}++// RouterLeaseChallenge is the payload a router signs with its enrolled key at+// POST /routers/lease, carried in RouterLeaseRequest's+// timestamp/challenge_signature fields. The router's biscuit is not proof on+// its own: routers send it to every peer they authenticate.+func RouterLeaseChallenge(peerID string, ts int64) []byte {+ return []byte("sam:routers-lease:" + peerID + ":" + strconv.FormatInt(ts, 10))+}+// ============================================================================// SAM Custom HTTP Headers// ============================================================================diff --git a/api/sam.pb.go b/api/sam.pb.goindex ef5db6e7..d9aa4934 100644--- a/api/sam.pb.go+++ b/api/sam.pb.go@@ -398,9 +398,17 @@ type EnrollRequest struct {// Validated fail-closed by the control plane and, once attested by the// enrollment flow's gates, minted as signed label() facts in the// biscuit. Empty means no claims.- Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`+ // Proof of possession of public_key's private half: timestamp is unix+ // milliseconds and challenge_signature signs the UTF-8 bytes of+ // "sam:register:<peer_id>:<timestamp>". Required, and peer_id must be+ // derived from public_key. The JWT proves who is asking; this proves+ // they hold the key they are asking to bind, so an identity cannot+ // register (and overwrite) another node's peer_id.+ Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`+ ChallengeSignature []byte `protobuf:"bytes,7,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *EnrollRequest) Reset() {@@ -468,6 +476,20 @@ func (x *EnrollRequest) GetLabels() map[string]string {return nil}+func (x *EnrollRequest) GetTimestamp() int64 {+ if x != nil {+ return x.Timestamp+ }+ return 0+}++func (x *EnrollRequest) GetChallengeSignature() []byte {+ if x != nil {+ return x.ChallengeSignature+ }+ return nil+}+type EnrollResponse struct {state protoimpl.MessageState `protogen:"open.v1"`BiscuitToken []byte `protobuf:"bytes,1,opt,name=biscuit_token,json=biscuitToken,proto3" json:"biscuit_token,omitempty"`@@ -1210,8 +1232,15 @@ type RouterLeaseRequest struct {Biscuit []byte `protobuf:"bytes,3,opt,name=biscuit,proto3" json:"biscuit,omitempty"`ConnectedPeers []string `protobuf:"bytes,4,rep,name=connected_peers,json=connectedPeers,proto3" json:"connected_peers,omitempty"`DhtSize int32 `protobuf:"varint,5,opt,name=dht_size,json=dhtSize,proto3" json:"dht_size,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ // Proof of possession of the router's enrolled key: timestamp is unix+ // milliseconds and challenge_signature signs the UTF-8 bytes of+ // "sam:routers-lease:<peer_id>:<timestamp>" with the key the router+ // enrolled with. Required. The biscuit alone is not proof: routers hand+ // theirs to every peer they authenticate.+ Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`+ ChallengeSignature []byte `protobuf:"bytes,7,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *RouterLeaseRequest) Reset() {@@ -1279,6 +1308,20 @@ func (x *RouterLeaseRequest) GetDhtSize() int32 {return 0}+func (x *RouterLeaseRequest) GetTimestamp() int64 {+ if x != nil {+ return x.Timestamp+ }+ return 0+}++func (x *RouterLeaseRequest) GetChallengeSignature() []byte {+ if x != nil {+ return x.ChallengeSignature+ }+ return nil+}+type RouterLeaseResponse struct {state protoimpl.MessageState `protogen:"open.v1"`Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`@@ -2981,14 +3024,16 @@ const file_api_sam_proto_rawDesc = "" +"\n" +"\x06BANNED\x10\x00\x12\x10\n" +"\fKEY_ROTATION\x10\x01\x12\x11\n" +- "\rPOLICY_UPDATE\x10\x02\"\xf6\x01\n" ++ "\rPOLICY_UPDATE\x10\x02\"\xc5\x02\n" +"\rEnrollRequest\x12\x10\n" +"\x03jwt\x18\x01 \x01(\tR\x03jwt\x12\x17\n" +"\apeer_id\x18\x02 \x01(\tR\x06peerId\x12\x1d\n" +"\n" +"public_key\x18\x03 \x01(\fR\tpublicKey\x12%\n" +"\x0erequested_role\x18\x04 \x01(\tR\rrequestedRole\x129\n" +- "\x06labels\x18\x05 \x03(\v2!.sam.v1.EnrollRequest.LabelsEntryR\x06labels\x1a9\n" ++ "\x06labels\x18\x05 \x03(\v2!.sam.v1.EnrollRequest.LabelsEntryR\x06labels\x12\x1c\n" ++ "\ttimestamp\x18\x06 \x01(\x03R\ttimestamp\x12/\n" ++ "\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\x1a9\n" +"\vLabelsEntry\x12\x10\n" +"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xde\x01\n" +@@ -3061,13 +3106,15 @@ const file_api_sam_proto_rawDesc = "" +"\tclient_id\x18\x02 \x01(\tR\bclientId\x12\x1a\n" +"\baudience\x18\x03 \x01(\tR\baudience\x12)\n" +"\x10router_addresses\x18\x04 \x03(\tR\x0frouterAddresses\x12&\n" +- "\x0fbanned_peer_ids\x18\x05 \x03(\tR\rbannedPeerIds\"\xa9\x01\n" ++ "\x0fbanned_peer_ids\x18\x05 \x03(\tR\rbannedPeerIds\"\xf8\x01\n" +"\x12RouterLeaseRequest\x12\x17\n" +"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12\x1c\n" +"\taddresses\x18\x02 \x03(\tR\taddresses\x12\x18\n" +"\abiscuit\x18\x03 \x01(\fR\abiscuit\x12'\n" +"\x0fconnected_peers\x18\x04 \x03(\tR\x0econnectedPeers\x12\x19\n" +- "\bdht_size\x18\x05 \x01(\x05R\adhtSize\"d\n" ++ "\bdht_size\x18\x05 \x01(\x05R\adhtSize\x12\x1c\n" ++ "\ttimestamp\x18\x06 \x01(\x03R\ttimestamp\x12/\n" ++ "\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\"d\n" +"\x13RouterLeaseResponse\x12\x18\n" +"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +"\x05error\x18\x02 \x01(\tR\x05error\x12\x1d\n" +diff --git a/api/sam.proto b/api/sam.protoindex af68cd2a..8368982b 100644--- a/api/sam.proto+++ b/api/sam.proto@@ -60,6 +60,14 @@ message EnrollRequest {// enrollment flow's gates, minted as signed label() facts in the// biscuit. Empty means no claims.map<string, string> labels = 5;+ // Proof of possession of public_key's private half: timestamp is unix+ // milliseconds and challenge_signature signs the UTF-8 bytes of+ // "sam:register:<peer_id>:<timestamp>". Required, and peer_id must be+ // derived from public_key. The JWT proves who is asking; this proves+ // they hold the key they are asking to bind, so an identity cannot+ // register (and overwrite) another node's peer_id.+ int64 timestamp = 6;+ bytes challenge_signature = 7;}message EnrollResponse {@@ -186,6 +194,13 @@ message RouterLeaseRequest {bytes biscuit = 3;repeated string connected_peers = 4;int32 dht_size = 5;+ // Proof of possession of the router's enrolled key: timestamp is unix+ // milliseconds and challenge_signature signs the UTF-8 bytes of+ // "sam:routers-lease:<peer_id>:<timestamp>" with the key the router+ // enrolled with. Required. The biscuit alone is not proof: routers hand+ // theirs to every peer they authenticate.+ int64 timestamp = 6;+ bytes challenge_signature = 7;}message RouterLeaseResponse {diff --git a/internal/controlplane/biscuit_ttl_test.go b/internal/controlplane/biscuit_ttl_test.goindex fbe53eff..96e3b5ac 100644--- a/internal/controlplane/biscuit_ttl_test.go+++ b/internal/controlplane/biscuit_ttl_test.go@@ -87,11 +87,14 @@ func registerNode(t *testing.T, cpURL, jwtToken string) (crypto.PrivKey, peer.IDt.Fatal(err)}+ ts, sig := registerPoP(t, priv, peerID.String())reqData, err := proto.Marshal(&api.EnrollRequest{- Jwt: jwtToken,- PeerId: peerID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: jwtToken,+ PeerId: peerID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,})if err != nil {t.Fatal(err)diff --git a/internal/controlplane/label_grants_test.go b/internal/controlplane/label_grants_test.goindex ccf9ed11..94741699 100644--- a/internal/controlplane/label_grants_test.go+++ b/internal/controlplane/label_grants_test.go@@ -77,12 +77,15 @@ func TestRegisterRefusesLabelsTheRoleDoesNotGrant(t *testing.T) {t.Fatal(err)}+ ts, sig := registerPoP(t, priv, pID.String())body, err := proto.Marshal(&api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": "node-alice"}),- PeerId: pID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,- Labels: labels,+ Jwt: mintToken(map[string]interface{}{"sub": "node-alice"}),+ PeerId: pID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Labels: labels,+ Timestamp: ts,+ ChallengeSignature: sig,})if err != nil {t.Fatal(err)diff --git a/internal/controlplane/peer_id_canonicalization_test.go b/internal/controlplane/peer_id_canonicalization_test.goindex 5ed436fa..910e0554 100644--- a/internal/controlplane/peer_id_canonicalization_test.go+++ b/internal/controlplane/peer_id_canonicalization_test.go@@ -135,11 +135,20 @@ func TestBannedNodeCannotRegisterUnderAnAlias(t *testing.T) {if err != nil {t.Fatal(err)}+ // The challenge is over the canonical id whatever spelling the request+ // carries, as the control plane canonicalizes before checking it.+ decoded, err := peer.Decode(peerID)+ if err != nil {+ t.Fatal(err)+ }+ ts, sig := registerPoP(t, priv, decoded.String())reqData, err := proto.Marshal(&api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": sub}),- PeerId: peerID,- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: mintToken(map[string]interface{}{"sub": sub}),+ PeerId: peerID,+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,})if err != nil {t.Fatalf("failed to marshal enroll request: %v", err)diff --git a/internal/controlplane/policies_admission_test.go b/internal/controlplane/policies_admission_test.goindex c9abd84c..bf034161 100644--- a/internal/controlplane/policies_admission_test.go+++ b/internal/controlplane/policies_admission_test.go@@ -64,11 +64,14 @@ func TestPoliciesRequiresAnAdmissibleNode(t *testing.T) {t.Fatal(err)}+ ts, sig := registerPoP(t, privNode, nodePeer.String())enrollReq := &api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": "node-alice", "groups": []string{"users"}}),- PeerId: nodePeer.String(),- PublicKey: nodePubKeyBytes,- RequestedRole: api.RoleNode,+ Jwt: mintToken(map[string]interface{}{"sub": "node-alice", "groups": []string{"users"}}),+ PeerId: nodePeer.String(),+ PublicKey: nodePubKeyBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,}reqData, err := proto.Marshal(enrollReq)if err != nil {diff --git a/internal/controlplane/server.go b/internal/controlplane/server.goindex 429c14ec..21063266 100644--- a/internal/controlplane/server.go+++ b/internal/controlplane/server.go@@ -510,6 +510,28 @@ func (s *Server) HandleRegister(w http.ResponseWriter, r *http.Request) {}canonical := pID.String()+ // Proof of possession, as at /enroll: the JWT says who is asking, this+ // says they hold the key they are binding. Without it any identity with+ // a node binding could register a victim's peer_id and overwrite its+ // record. peer_id must be the key's own, so the same peer_id always+ // means the same key and a record can only ever be overwritten by its+ // owner.+ enrolleeKey, err := crypto.UnmarshalPublicKey(req.PublicKey)+ if err != nil {+ http.Error(w, "Invalid public key", http.StatusBadRequest)+ return+ }+ if !pID.MatchesPublicKey(enrolleeKey) {+ logger.Warnw("Registration peer_id does not match public_key", "peer_id", canonical)+ http.Error(w, "peer_id is not derived from public_key", http.StatusBadRequest)+ return+ }+ if err := verifyFreshChallenge(enrolleeKey, api.RegisterChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {+ logger.Warnw("Register challenge verification failed", "peer_id", canonical, "error", err)+ http.Error(w, "Invalid registration challenge: "+err.Error(), http.StatusUnauthorized)+ return+ }+// A ban names the device key and the identity behind it; check both, or// a banned node re-enrolls from a freshly generated keypair.if banned, err := s.store.IsNodeBanned(ctx, canonical); err != nil {@@ -1023,6 +1045,29 @@ func (s *Server) HandleRouterLease(w http.ResponseWriter, r *http.Request) {http.Error(w, "Session expired, please re-enroll", http.StatusUnauthorized)return}+ // The biscuit's role() fact was checked above; this is the control+ // plane's own record of what it enrolled this peer as.+ if routerRecord.Role != api.RoleRouter {+ logger.Warnw("Lease renewal from a peer not enrolled as a router", "peer_id", canonical, "role", routerRecord.Role)+ http.Error(w, "Unauthorized: entity is not a router", http.StatusForbidden)+ return+ }++ // Proof of possession. The biscuit is not it: routers send theirs to+ // every peer they authenticate, so any enrolled node holds a router's+ // biscuit and could otherwise rewrite that router's lease (empty or+ // attacker addresses, false telemetry) for every joining peer.+ routerKey, err := crypto.UnmarshalPublicKey(routerRecord.PublicKey)+ if err != nil {+ logger.Errorf("Router %s has an unparseable enrolled public key: %v", canonical, err)+ http.Error(w, "Internal server error", http.StatusInternalServerError)+ return+ }+ if err := verifyFreshChallenge(routerKey, api.RouterLeaseChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {+ logger.Warnw("Router lease challenge verification failed", "peer_id", canonical, "error", err)+ http.Error(w, "Invalid lease challenge: "+err.Error(), http.StatusUnauthorized)+ return+ }// Advertised addresses are served verbatim to joining peers via /info and// /enroll: accept only well-formed multiaddrs terminating at thediff --git a/internal/controlplane/server_test.go b/internal/controlplane/server_test.goindex b297b480..e8cfef47 100644--- a/internal/controlplane/server_test.go+++ b/internal/controlplane/server_test.go@@ -317,11 +317,14 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {})nodePubKeyBytes, _ := crypto.MarshalPublicKey(privNode.GetPublic())+ nodeTS, nodeSig := registerPoP(t, privNode, nodePeer.String())enrollNodeReq := &api.EnrollRequest{- Jwt: nodeJWT,- PeerId: nodePeer.String(),- PublicKey: nodePubKeyBytes,- RequestedRole: api.RoleNode,+ Jwt: nodeJWT,+ PeerId: nodePeer.String(),+ PublicKey: nodePubKeyBytes,+ RequestedRole: api.RoleNode,+ Timestamp: nodeTS,+ ChallengeSignature: nodeSig,}reqData, _ := proto.Marshal(enrollNodeReq)@@ -361,11 +364,14 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {})routerPubKeyBytes, _ := crypto.MarshalPublicKey(privRouter.GetPublic())+ routerTS, routerSig := registerPoP(t, privRouter, routerPeer.String())enrollRouterReq := &api.EnrollRequest{- Jwt: routerJWT,- PeerId: routerPeer.String(),- PublicKey: routerPubKeyBytes,- RequestedRole: api.RoleRouter,+ Jwt: routerJWT,+ PeerId: routerPeer.String(),+ PublicKey: routerPubKeyBytes,+ RequestedRole: api.RoleRouter,+ Timestamp: routerTS,+ ChallengeSignature: routerSig,}reqData, _ = proto.Marshal(enrollRouterReq)@@ -389,10 +395,13 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {// 4. Register Router LeaserouterAddresses := []string{"/ip4/127.0.0.1/tcp/5001/p2p/" + routerPeer.String()}+ leaseTS, leaseSig := leasePoP(t, privRouter, routerPeer.String())leaseReq := &api.RouterLeaseRequest{- PeerId: routerPeer.String(),- Addresses: routerAddresses,- Biscuit: enrollRouterResp.BiscuitToken,+ PeerId: routerPeer.String(),+ Addresses: routerAddresses,+ Biscuit: enrollRouterResp.BiscuitToken,+ Timestamp: leaseTS,+ ChallengeSignature: leaseSig,}reqData, _ = proto.Marshal(leaseReq)@@ -437,10 +446,13 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {"missing p2p": "/ip4/203.0.113.66/tcp/4001","foreign peer": "/ip4/203.0.113.66/tcp/4001/p2p/" + nodePeer.String(),} {+ badTS, badSig := leasePoP(t, privRouter, routerPeer.String())badLease := &api.RouterLeaseRequest{- PeerId: routerPeer.String(),- Addresses: []string{badAddr},- Biscuit: enrollRouterResp.BiscuitToken,+ PeerId: routerPeer.String(),+ Addresses: []string{badAddr},+ Biscuit: enrollRouterResp.BiscuitToken,+ Timestamp: badTS,+ ChallengeSignature: badSig,}reqData, _ = proto.Marshal(badLease)resp, err = client.Post(baseURL+"/routers/lease", "application/x-protobuf", bytes.NewReader(reqData))@@ -454,10 +466,13 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {}// 6. Rogue Node tries to lease as a router (lacks 'router' role)+ rogueTS, rogueSig := leasePoP(t, privNode, nodePeer.String())rogueLeaseReq := &api.RouterLeaseRequest{- PeerId: nodePeer.String(),- Addresses: []string{"/ip4/127.0.0.1/tcp/6001/p2p/" + nodePeer.String()},- Biscuit: enrollNodeResp.BiscuitToken, // Node biscuit doesn't have router role+ PeerId: nodePeer.String(),+ Addresses: []string{"/ip4/127.0.0.1/tcp/6001/p2p/" + nodePeer.String()},+ Biscuit: enrollNodeResp.BiscuitToken, // Node biscuit doesn't have router role+ Timestamp: rogueTS,+ ChallengeSignature: rogueSig,}reqData, _ = proto.Marshal(rogueLeaseReq)@@ -468,6 +483,72 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {if resp.StatusCode != http.StatusForbidden {t.Errorf("expectedStatusForbidden (403) for rogue router lease, got: %s", resp.Status)}++ // 7. Lease poisoning by an enrolled node. Routers send their biscuit to+ // every peer they authenticate, so the node holds a copy; a lease that+ // needed only the biscuit let it rewrite the router's addresses for every+ // joining peer. The node signs the challenge with the only key it has.+ for name, poisoned := range map[string]*api.RouterLeaseRequest{+ "no challenge": {+ PeerId: routerPeer.String(),+ Addresses: []string{},+ Biscuit: enrollRouterResp.BiscuitToken,+ },+ "challenge signed with the node's key": func() *api.RouterLeaseRequest {+ ts, sig := leasePoP(t, privNode, routerPeer.String())+ return &api.RouterLeaseRequest{+ PeerId: routerPeer.String(),+ Addresses: []string{"/ip4/203.0.113.66/tcp/4001/p2p/" + routerPeer.String()},+ Biscuit: enrollRouterResp.BiscuitToken,+ Timestamp: ts,+ ChallengeSignature: sig,+ }+ }(),+ "stale router signature": func() *api.RouterLeaseRequest {+ ts := time.Now().Add(-challengeMaxAge - time.Minute).UnixMilli()+ sig, err := privRouter.Sign(api.RouterLeaseChallenge(routerPeer.String(), ts))+ if err != nil {+ t.Fatal(err)+ }+ return &api.RouterLeaseRequest{+ PeerId: routerPeer.String(),+ Addresses: []string{},+ Biscuit: enrollRouterResp.BiscuitToken,+ Timestamp: ts,+ ChallengeSignature: sig,+ }+ }(),+ } {+ reqData, err := proto.Marshal(poisoned)+ if err != nil {+ t.Fatalf("marshal poisoned lease (%s): %v", name, err)+ }+ resp, err = client.Post(baseURL+"/routers/lease", "application/x-protobuf", bytes.NewReader(reqData))+ if err != nil {+ t.Fatalf("POST poisoned lease (%s) failed: %v", name, err)+ }+ _ = resp.Body.Close()+ if resp.StatusCode != http.StatusUnauthorized {+ t.Errorf("poisoned lease (%s): got %s, want 401", name, resp.Status)+ }+ }+ // The router's advertised addresses are untouched.+ resp, err = client.Get(baseURL + "/info")+ if err != nil {+ t.Fatalf("GET /info failed: %v", err)+ }+ body, err = io.ReadAll(resp.Body)+ _ = resp.Body.Close()+ if err != nil {+ t.Fatalf("read /info: %v", err)+ }+ var infoAfter api.ControlPlaneInfoResponse+ if err := proto.Unmarshal(body, &infoAfter); err != nil {+ t.Fatalf("unmarshal /info: %v", err)+ }+ if !reflect.DeepEqual(infoAfter.RouterAddresses, routerAddresses) {+ t.Errorf("router addresses after poisoning attempts = %v, want %v", infoAfter.RouterAddresses, routerAddresses)+ }}// The console renders this JSON for editing and posts the result straight back,@@ -986,6 +1067,163 @@ func enrollPoP(t *testing.T, priv crypto.PrivKey, peerID string) (int64, []byte)return ts, sig}+// registerPoP signs the POST /register proof-of-possession challenge.+func registerPoP(t *testing.T, priv crypto.PrivKey, peerID string) (int64, []byte) {+ t.Helper()+ ts := time.Now().UnixMilli()+ sig, err := priv.Sign(api.RegisterChallenge(peerID, ts))+ if err != nil {+ t.Fatalf("failed to sign register challenge: %v", err)+ }+ return ts, sig+}++// leasePoP signs the POST /routers/lease proof-of-possession challenge.+func leasePoP(t *testing.T, priv crypto.PrivKey, peerID string) (int64, []byte) {+ t.Helper()+ ts := time.Now().UnixMilli()+ sig, err := priv.Sign(api.RouterLeaseChallenge(peerID, ts))+ if err != nil {+ t.Fatalf("failed to sign lease challenge: %v", err)+ }+ return ts, sig+}++// TestRegisterRequiresProofOfPossession pins audit finding H1: POST /register+// trusted peer_id from the body, so any OIDC identity with a node binding+// could register a victim's peer_id with any public key, overwrite the+// victim's record (NULLing owner_id and autonomous_recovery) and break the+// victim's next /refresh. The JWT says who is asking; the signed challenge+// says they hold the key they are binding.+func TestRegisterRequiresProofOfPossession(t *testing.T) {+ issuer, mintToken := startCustomMockOIDC(t)+ srv, store, baseURL := setupTestServer(t, issuer)+ defer func() {+ _ = srv.Close()+ _ = store.Close()+ }()+ ctx := context.Background()+ client := &http.Client{Timeout: 5 * time.Second}++ if err := store.SaveMeshPolicy(ctx, nil, []*api.PolicyBinding{+ {Role: api.RoleNode, Members: []string{api.SystemAuthenticated}},+ }); err != nil {+ t.Fatal(err)+ }++ post := func(req *api.EnrollRequest) (int, string) {+ t.Helper()+ data, err := proto.Marshal(req)+ if err != nil {+ t.Fatal(err)+ }+ resp, err := client.Post(baseURL+"/register", "application/x-protobuf", bytes.NewReader(data))+ if err != nil {+ t.Fatalf("/register failed: %v", err)+ }+ defer func() { _ = resp.Body.Close() }()+ body, err := io.ReadAll(resp.Body)+ if err != nil {+ t.Fatalf("read /register response: %v", err)+ }+ return resp.StatusCode, string(body)+ }++ victimPriv, victimID := newTestKey(t)+ victimPub, err := crypto.MarshalPublicKey(victimPriv.GetPublic())+ if err != nil {+ t.Fatal(err)+ }+ attackerPriv, attackerID := newTestKey(t)+ attackerPub, err := crypto.MarshalPublicKey(attackerPriv.GetPublic())+ if err != nil {+ t.Fatal(err)+ }++ // The victim enrolls, with the admin-granted flag the hijack used to strip.+ ts, sig := registerPoP(t, victimPriv, victimID.String())+ if status, body := post(&api.EnrollRequest{+ Jwt: mintToken(map[string]interface{}{"sub": "victim"}), PeerId: victimID.String(), PublicKey: victimPub,+ RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,+ }); status != http.StatusOK {+ t.Fatalf("victim registration: got %d (%s), want 200", status, body)+ }+ if err := store.SetNodeAutonomousRecovery(ctx, victimID.String(), true); err != nil {+ t.Fatal(err)+ }++ attackerJWT := mintToken(map[string]interface{}{"sub": "attacker"})+ cases := map[string]struct {+ req *api.EnrollRequest+ want int+ }{+ "victim peer_id, attacker key, no challenge": {+ req: &api.EnrollRequest{Jwt: attackerJWT, PeerId: victimID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode},+ want: http.StatusBadRequest, // peer_id is not the key's own+ },+ "victim peer_id and public key, no challenge": {+ req: &api.EnrollRequest{Jwt: attackerJWT, PeerId: victimID.String(), PublicKey: victimPub, RequestedRole: api.RoleNode},+ want: http.StatusUnauthorized,+ },+ "victim peer_id and public key, challenge signed by the attacker": {+ req: func() *api.EnrollRequest {+ ts, sig := registerPoP(t, attackerPriv, victimID.String())+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: victimID.String(), PublicKey: victimPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}+ }(),+ want: http.StatusUnauthorized,+ },+ "own key, challenge for another endpoint": {+ req: func() *api.EnrollRequest {+ ts, sig := enrollPoP(t, attackerPriv, attackerID.String())+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}+ }(),+ want: http.StatusUnauthorized,+ },+ "own key, stale challenge": {+ req: func() *api.EnrollRequest {+ ts := time.Now().Add(-challengeMaxAge - time.Minute).UnixMilli()+ sig, err := attackerPriv.Sign(api.RegisterChallenge(attackerID.String(), ts))+ if err != nil {+ t.Fatal(err)+ }+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}+ }(),+ want: http.StatusUnauthorized,+ },+ }+ for name, tc := range cases {+ t.Run(name, func(t *testing.T) {+ if status, body := post(tc.req); status != tc.want {+ t.Errorf("got %d (%s), want %d", status, body, tc.want)+ }+ })+ }++ // The victim's record survived every attempt intact.+ victim, err := store.GetNode(ctx, victimID.String())+ if err != nil {+ t.Fatalf("victim record: %v", err)+ }+ if !bytes.Equal(victim.PublicKey, victimPub) {+ t.Error("victim's public key was overwritten")+ }+ if !victim.AutonomousRecovery {+ t.Error("victim's autonomous_recovery flag was reset")+ }+ if _, err := store.GetNode(ctx, attackerID.String()); err != storage.ErrNotFound {+ t.Errorf("attacker's failed attempts left a record: err = %v", err)+ }++ // The same attacker, proving its own key, registers normally.+ ts, sig = registerPoP(t, attackerPriv, attackerID.String())+ if status, body := post(&api.EnrollRequest{+ Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub,+ RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,+ }); status != http.StatusOK {+ t.Fatalf("honest registration: got %d (%s), want 200", status, body)+ }+}+// TestBootstrapEnrollmentRequiresProofOfPossession pins the fix for// GHSA-hp3x-79wr-rx66 on both bootstrap endpoints: neither GET /enroll/status// nor a repeated POST /enroll may reveal an enrollment's status or biscuit to@@ -1256,7 +1494,7 @@ func TestRouterLeaseRevocation(t *testing.T) {// enrollLeaseRouter mints a router biscuit and, unless orphan, the// EnrolledNode record backing it.- enrollLeaseRouter := func(expiresAt time.Time, orphan bool) (peer.ID, []byte) {+ enrollLeaseRouter := func(expiresAt time.Time, orphan bool) (crypto.PrivKey, peer.ID, []byte) {t.Helper()priv, pub, err := crypto.GenerateKeyPair(crypto.Ed25519, -1)if err != nil {@@ -1281,15 +1519,18 @@ func TestRouterLeaseRevocation(t *testing.T) {t.Fatal(err)}}- return routerPeer, routerBiscuit+ return priv, routerPeer, routerBiscuit}- postLease := func(routerPeer peer.ID, routerBiscuit []byte) int {+ postLease := func(priv crypto.PrivKey, routerPeer peer.ID, routerBiscuit []byte) int {t.Helper()+ ts, sig := leasePoP(t, priv, routerPeer.String())leaseData, _ := proto.Marshal(&api.RouterLeaseRequest{- PeerId: routerPeer.String(),- Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},- Biscuit: routerBiscuit,+ PeerId: routerPeer.String(),+ Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},+ Biscuit: routerBiscuit,+ Timestamp: ts,+ ChallengeSignature: sig,})resp, err := client.Post(baseURL+"/routers/lease", "application/x-protobuf", bytes.NewReader(leaseData))if err != nil {@@ -1300,8 +1541,8 @@ func TestRouterLeaseRevocation(t *testing.T) {}// Admitted router renews; the same router refuses after /admin/revoke.- routerPeer, routerBiscuit := enrollLeaseRouter(time.Time{}, false)- if got := postLease(routerPeer, routerBiscuit); got != http.StatusOK {+ routerPriv, routerPeer, routerBiscuit := enrollLeaseRouter(time.Time{}, false)+ if got := postLease(routerPriv, routerPeer, routerBiscuit); got != http.StatusOK {t.Fatalf("lease before revocation: got %d, want 200", got)}revokeData, _ := proto.Marshal(&api.TokenRevokeRequest{PeerId: routerPeer.String()})@@ -1315,19 +1556,19 @@ func TestRouterLeaseRevocation(t *testing.T) {if resp.StatusCode != http.StatusOK {t.Fatalf("revoke: got %s, want 200", resp.Status)}- if got := postLease(routerPeer, routerBiscuit); got != http.StatusForbidden {+ if got := postLease(routerPriv, routerPeer, routerBiscuit); got != http.StatusForbidden {t.Fatalf("lease after revocation: got %d, want 403", got)}// A lapsed OIDC session is the other admission arm.- expiredPeer, expiredBiscuit := enrollLeaseRouter(time.Now().Add(-time.Hour), false)- if got := postLease(expiredPeer, expiredBiscuit); got != http.StatusUnauthorized {+ expiredPriv, expiredPeer, expiredBiscuit := enrollLeaseRouter(time.Now().Add(-time.Hour), false)+ if got := postLease(expiredPriv, expiredPeer, expiredBiscuit); got != http.StatusUnauthorized {t.Fatalf("lease with lapsed session: got %d, want 401", got)}// A valid biscuit with no enrollment record behind it renews nothing.- orphanPeer, orphanBiscuit := enrollLeaseRouter(time.Time{}, true)- if got := postLease(orphanPeer, orphanBiscuit); got != http.StatusUnauthorized {+ orphanPriv, orphanPeer, orphanBiscuit := enrollLeaseRouter(time.Time{}, true)+ if got := postLease(orphanPriv, orphanPeer, orphanBiscuit); got != http.StatusUnauthorized {t.Fatalf("lease without enrollment record: got %d, want 401", got)}}@@ -1387,10 +1628,13 @@ func TestRouterLeaseUnderRotatedKey(t *testing.T) {t.Fatal(err)}+ leaseTS, leaseSig := leasePoP(t, priv, routerPeer.String())leaseData, err := proto.Marshal(&api.RouterLeaseRequest{- PeerId: routerPeer.String(),- Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},- Biscuit: routerBiscuit,+ PeerId: routerPeer.String(),+ Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},+ Biscuit: routerBiscuit,+ Timestamp: leaseTS,+ ChallengeSignature: leaseSig,})if err != nil {t.Fatal(err)@@ -1622,11 +1866,14 @@ func TestTokenRefreshAndRevocation(t *testing.T) {})nodePubKeyBytes, _ := crypto.MarshalPublicKey(pubNode)+ nodeTS, nodeSig := registerPoP(t, privNode, nodePeer.String())enrollNodeReq := &api.EnrollRequest{- Jwt: nodeJWT,- PeerId: nodePeer.String(),- PublicKey: nodePubKeyBytes,- RequestedRole: api.RoleNode,+ Jwt: nodeJWT,+ PeerId: nodePeer.String(),+ PublicKey: nodePubKeyBytes,+ RequestedRole: api.RoleNode,+ Timestamp: nodeTS,+ ChallengeSignature: nodeSig,}reqData, _ := proto.Marshal(enrollNodeReq)@@ -1758,11 +2005,14 @@ func TestNodeProactiveTokenRefresh(t *testing.T) {// Enroll via registration endpointnodePubKeyBytes, _ := crypto.MarshalPublicKey(pubNode)+ nodeTS, nodeSig := registerPoP(t, privNode, nodePeer.String())enrollNodeReq := &api.EnrollRequest{- Jwt: nodeJWT,- PeerId: nodePeer.String(),- PublicKey: nodePubKeyBytes,- RequestedRole: api.RoleNode,+ Jwt: nodeJWT,+ PeerId: nodePeer.String(),+ PublicKey: nodePubKeyBytes,+ RequestedRole: api.RoleNode,+ Timestamp: nodeTS,+ ChallengeSignature: nodeSig,}reqData, _ := proto.Marshal(enrollNodeReq)@@ -2199,11 +2449,14 @@ func TestAuthDenialPaths(t *testing.T) {t.Fatal(err)}pubBytes, _ := crypto.MarshalPublicKey(pubNode)+ ts, sig := registerPoP(t, privNode, pID.String())reqData, _ := proto.Marshal(&api.EnrollRequest{- Jwt: jwtStr,- PeerId: pID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: jwtStr,+ PeerId: pID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,})return reqData}@@ -2347,11 +2600,14 @@ func TestOIDCSessionTTLIsConfigurable(t *testing.T) {}pubBytes, _ := crypto.MarshalPublicKey(pubNode)enrolledAt := time.Now()+ regTS, regSig := registerPoP(t, privNode, nodePeer.String())reqData, _ := proto.Marshal(&api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": "short-session"}),- PeerId: nodePeer.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: mintToken(map[string]interface{}{"sub": "short-session"}),+ PeerId: nodePeer.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: regTS,+ ChallengeSignature: regSig,})resp, err := client.Post(baseURL+"/register", "application/x-protobuf", bytes.NewReader(reqData))if err != nil {@@ -2439,11 +2695,14 @@ func TestBanSurvivesKeypairRegeneration(t *testing.T) {if err != nil {t.Fatal(err)}+ ts, sig := registerPoP(t, priv, pID.String())reqData, _ := proto.Marshal(&api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": sub}),- PeerId: pID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: mintToken(map[string]interface{}{"sub": sub}),+ PeerId: pID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,})resp, err := client.Post(baseURL+"/register", "application/x-protobuf", bytes.NewReader(reqData))if err != nil {diff --git a/internal/node/enroll.go b/internal/node/enroll.goindex 1e91e2e5..5d212a92 100644--- a/internal/node/enroll.go+++ b/internal/node/enroll.go@@ -64,8 +64,7 @@ func GetOrGenerateKey(s *Store) crypto.PrivKey {}func (n *SamNode) Enroll(ctx context.Context, controlPlaneURL string, jwt string) error {- pubKey := n.Host.Peerstore().PubKey(n.Host.ID())- enrollResp, err := n.enrollHTTP(ctx, controlPlaneURL, jwt, n.Host.ID(), pubKey)+ enrollResp, err := n.enrollHTTP(ctx, controlPlaneURL, jwt, n.Host.ID(), n.config.PrivKey)if err != nil {return err}@@ -75,18 +74,26 @@ func (n *SamNode) Enroll(ctx context.Context, controlPlaneURL string, jwt string// enrollHTTP performs the HTTP half of enrollment for an explicit peer// identity, so it can run before the libp2p host exists (startup recovery).-func (n *SamNode) enrollHTTP(ctx context.Context, controlPlaneURL, jwt string, peerID peer.ID, pubKey crypto.PubKey) (*api.EnrollResponse, error) {- pubBytes, err := crypto.MarshalPublicKey(pubKey)+// privKey signs the proof-of-possession challenge; peerID must be its own.+func (n *SamNode) enrollHTTP(ctx context.Context, controlPlaneURL, jwt string, peerID peer.ID, privKey crypto.PrivKey) (*api.EnrollResponse, error) {+ pubBytes, err := crypto.MarshalPublicKey(privKey.GetPublic())if err != nil {return nil, fmt.Errorf("failed to marshal public key: %w", err)}+ ts := time.Now().UnixMilli()+ sig, err := privKey.Sign(api.RegisterChallenge(peerID.String(), ts))+ if err != nil {+ return nil, fmt.Errorf("failed to sign registration challenge: %w", err)+ }req := &api.EnrollRequest{- Jwt: jwt,- PeerId: peerID.String(),- PublicKey: pubBytes,- RequestedRole: n.config.RequiredRole,- Labels: n.labels(),+ Jwt: jwt,+ PeerId: peerID.String(),+ PublicKey: pubBytes,+ RequestedRole: n.config.RequiredRole,+ Labels: n.labels(),+ Timestamp: ts,+ ChallengeSignature: sig,}data, err := proto.Marshal(req)if err != nil {@@ -136,7 +143,7 @@ func (n *SamNode) ReEnrollWithRefreshToken(ctx context.Context) error {if err != nil {return fmt.Errorf("failed to derive peer ID from stored key: %w", err)}- _, err = n.enrollHTTP(ctx, controlPlaneURL, jwt, peerID, privKey.GetPublic())+ _, err = n.enrollHTTP(ctx, controlPlaneURL, jwt, peerID, privKey)return err}diff --git a/internal/router/router.go b/internal/router/router.goindex 781f8f4e..00eeb140 100644--- a/internal/router/router.go+++ b/internal/router/router.go@@ -376,12 +376,19 @@ func (r *Router) enroll(peerID peer.ID) error {if err != nil {return fmt.Errorf("failed to marshal public key: %w", err)}+ ts := time.Now().UnixMilli()+ sig, err := r.privKey.Sign(api.RegisterChallenge(peerID.String(), ts))+ if err != nil {+ return fmt.Errorf("failed to sign registration challenge: %w", err)+ }req := &api.EnrollRequest{- Jwt: r.config.OIDCToken,- PeerId: peerID.String(),- PublicKey: pubBytes,- RequestedRole: r.config.RequiredRole,+ Jwt: r.config.OIDCToken,+ PeerId: peerID.String(),+ PublicKey: pubBytes,+ RequestedRole: r.config.RequiredRole,+ Timestamp: ts,+ ChallengeSignature: sig,}data, err := proto.Marshal(req)if err != nil {@@ -823,12 +830,23 @@ func (r *Router) renewLease() {dhtSize = int32(r.DHT.RoutingTable().Size())}+ // The biscuit identifies us; the signature proves it is us (peers we+ // authenticate hold a copy of the biscuit).+ ts := time.Now().UnixMilli()+ sig, err := r.privKey.Sign(api.RouterLeaseChallenge(r.Host.ID().String(), ts))+ if err != nil {+ logger.Errorf("Failed to sign lease challenge: %v", err)+ return+ }+req := &api.RouterLeaseRequest{- PeerId: r.Host.ID().String(),- Addresses: addrs,- Biscuit: biscuit,- ConnectedPeers: connectedPeers,- DhtSize: dhtSize,+ PeerId: r.Host.ID().String(),+ Addresses: addrs,+ Biscuit: biscuit,+ ConnectedPeers: connectedPeers,+ DhtSize: dhtSize,+ Timestamp: ts,+ ChallengeSignature: sig,}data, _ := proto.Marshal(req)diff --git a/internal/router/router_test.go b/internal/router/router_test.goindex 6ce11b50..e3a134f7 100644--- a/internal/router/router_test.go+++ b/internal/router/router_test.go@@ -233,11 +233,18 @@ func TestRouterIntegration(t *testing.T) {if err != nil {t.Fatal(err)}+ regTS := time.Now().UnixMilli()+ regSig, err := nodePrivKey.Sign(api.RegisterChallenge(nodePeerID.String(), regTS))+ if err != nil {+ t.Fatal(err)+ }enrollNodeReq := &api.EnrollRequest{- Jwt: nodeJWT,- PeerId: nodePeerID.String(),- PublicKey: nodePubKeyBytes,- RequestedRole: api.RoleNode,+ Jwt: nodeJWT,+ PeerId: nodePeerID.String(),+ PublicKey: nodePubKeyBytes,+ RequestedRole: api.RoleNode,+ Timestamp: regTS,+ ChallengeSignature: regSig,}reqData, _ := proto.Marshal(enrollNodeReq)resp, err := client.Post(cpURL+"/register", "application/x-protobuf", bytes.NewReader(reqData))@@ -538,6 +545,7 @@ func TestRouterLeaseRenewalRepeated401Terminates(t *testing.T) {r := &Router{Host: h,+ privKey: h.Peerstore().PrivKey(h.ID()),biscuitToken: []byte("dummy-biscuit"),config: Options{ControlPlaneURL: ts.URL,diff --git a/site/content/docs/user/control-plane-configuration.md b/site/content/docs/user/control-plane-configuration.mdindex 047df9ec..7d97da49 100644--- a/site/content/docs/user/control-plane-configuration.md+++ b/site/content/docs/user/control-plane-configuration.md@@ -186,7 +186,9 @@ Nodes and Routers run a background task that periodically checks the remaining BThe bootstrap surface requires the same proof of possession end to end. `POST /enroll` carries a signed timestamp challenge in the request body (`timestamp`/`challenge_signature`, and `peer_id` must be derived from the submitted `public_key`), so a bootstrap token alone can never mint — or re-fetch — another peer's Biscuit. `GET /enroll/status` answers only when the caller signs the peer-bound challenge with that same key, sent in the `X-Sam-Challenge-Ts` and `X-Sam-Challenge-Sig` headers (headers rather than query parameters, so signatures stay out of access logs). Anything else — no signature, a stale timestamp, another key, an unknown peer — receives a uniform `401`, so an approved enrollment's Biscuit is only ever released to the enrollee itself.-All three challenges share one shape — the UTF-8 bytes of `sam:<endpoint>:<peer_id>:<unix-millis>` (`sam:enroll:…`, `sam:enroll-status:…`, `sam:refresh:…`), signed by the peer's identity key and accepted within a ±5-minute freshness window. Binding the peer and the endpoint into the signed payload means a signature captured from any one request verifies nowhere else.+The OIDC surface and the router surface follow suit. `POST /register` carries the same `timestamp`/`challenge_signature` pair over `sam:register:…`, with `peer_id` derived from `public_key`: the ID token says who is asking, the signature says they hold the key they are binding, so an identity with a node binding cannot register — and overwrite — another node's `peer_id`. `POST /routers/lease` requires a challenge over `sam:routers-lease:…` signed with the key the router enrolled with; its Biscuit alone is not proof, because routers hand it to every peer they authenticate during the mutual handshake.++All five challenges share one shape — the UTF-8 bytes of `sam:<endpoint>:<peer_id>:<unix-millis>` (`sam:register:…`, `sam:enroll:…`, `sam:enroll-status:…`, `sam:refresh:…`, `sam:routers-lease:…`), signed by the peer's identity key and accepted within a ±5-minute freshness window. Binding the peer and the endpoint into the signed payload means a signature captured from any one request verifies nowhere else. Libp2p's secure channel already proves key possession on every peer-to-peer stream; these challenges exist because the Control Plane API is plain HTTP, where a `peer_id` in a request body is otherwise just a claim.### Signing-Key Retirement and Recoverydiff --git a/tests/integration/biscuit_expiry_test.go b/tests/integration/biscuit_expiry_test.goindex 60f00af6..1e0eb464 100644--- a/tests/integration/biscuit_expiry_test.go+++ b/tests/integration/biscuit_expiry_test.go@@ -98,10 +98,6 @@ func TestBiscuitExpiryIsEnforcedOnEveryPath(t *testing.T) {if err != nil {t.Fatal(err)}- pubBytes, err := crypto.MarshalPublicKey(pubKey)- if err != nil {- t.Fatal(err)- }jwtToken := mintToken(map[string]interface{}{"sub": "expiry-user",@@ -109,7 +105,7 @@ func TestBiscuitExpiryIsEnforcedOnEveryPath(t *testing.T) {})mintedAt := time.Now()- enrollResp := registerOnControlPlane(t, cpPort, peerID, pubBytes, jwtToken)+ enrollResp := registerOnControlPlane(t, cpPort, peerID, privKey, jwtToken)biscuitToken := enrollResp.BiscuitTokencpPubKey := ed25519.PublicKey(enrollResp.ControlPlanePublicKey)@@ -157,14 +153,25 @@ func TestBiscuitExpiryIsEnforcedOnEveryPath(t *testing.T) {}}-func registerOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, pubBytes []byte, jwtToken string) *api.EnrollResponse {+func registerOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, privKey crypto.PrivKey, jwtToken string) *api.EnrollResponse {t.Helper()+ pubBytes, err := crypto.MarshalPublicKey(privKey.GetPublic())+ if err != nil {+ t.Fatal(err)+ }+ ts := time.Now().UnixMilli()+ sig, err := privKey.Sign(api.RegisterChallenge(clientID.String(), ts))+ if err != nil {+ t.Fatal(err)+ }reqBytes, err := proto.Marshal(&api.EnrollRequest{- Jwt: jwtToken,- PeerId: clientID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: jwtToken,+ PeerId: clientID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,})if err != nil {t.Fatal(err)diff --git a/tests/integration/multimaster_test.go b/tests/integration/multimaster_test.goindex 0277e84b..0622da45 100644--- a/tests/integration/multimaster_test.go+++ b/tests/integration/multimaster_test.go@@ -215,12 +215,7 @@ roles: []}defer func() { _ = clientHost.Close() }()- pubKey := clientHost.Peerstore().PubKey(clientHost.ID())- pubBytes, err := crypto.MarshalPublicKey(pubKey)- if err != nil {- t.Fatal(err)- }- clientBiscuit := enrollClientOnControlPlane(t, portB, clientHost.ID(), pubBytes, nodeJWT)+ clientBiscuit := enrollClientOnControlPlane(t, portB, clientHost.ID(), clientHost.Peerstore().PrivKey(clientHost.ID()), nodeJWT)// 9. Assert that client host can connect and authenticate directly with Router A (registered with CP A!)// This proves Router A accepts biscuits issued by CP B because they share the key-ring.@@ -280,14 +275,25 @@ roles: []t.Log("Successfully verified multi-master control plane signature trust!")}-func enrollClientOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, pubBytes []byte, jwtToken string) []byte {+func enrollClientOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, privKey crypto.PrivKey, jwtToken string) []byte {t.Helper()+ pubBytes, err := crypto.MarshalPublicKey(privKey.GetPublic())+ if err != nil {+ t.Fatal(err)+ }+ ts := time.Now().UnixMilli()+ sig, err := privKey.Sign(api.RegisterChallenge(clientID.String(), ts))+ if err != nil {+ t.Fatal(err)+ }req := &api.EnrollRequest{- Jwt: jwtToken,- PeerId: clientID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,+ Jwt: jwtToken,+ PeerId: clientID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Timestamp: ts,+ ChallengeSignature: sig,}reqBytes, err := proto.Marshal(req)if err != nil {diff --git a/tests/integration/policy_grants_test.go b/tests/integration/policy_grants_test.goindex f755c21c..b04f87a4 100644--- a/tests/integration/policy_grants_test.go+++ b/tests/integration/policy_grants_test.go@@ -169,14 +169,20 @@ func TestPolicyGrantsReachTheMintedToken(t *testing.T) {if err != nil {t.Fatal(err)}- _ = privKey+ ts := time.Now().UnixMilli()+ sig, err := privKey.Sign(api.RegisterChallenge(peerID.String(), ts))+ if err != nil {+ t.Fatal(err)+ }reqBytes, err := proto.Marshal(&api.EnrollRequest{- Jwt: mintToken(map[string]interface{}{"sub": "node-alice"}),- PeerId: peerID.String(),- PublicKey: pubBytes,- RequestedRole: api.RoleNode,- Labels: labels,+ Jwt: mintToken(map[string]interface{}{"sub": "node-alice"}),+ PeerId: peerID.String(),+ PublicKey: pubBytes,+ RequestedRole: api.RoleNode,+ Labels: labels,+ Timestamp: ts,+ ChallengeSignature: sig,})if err != nil {t.Fatal(err)