Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,10 @@ func (hm *Manager) handleRequest(stream coreapi.Stream, msg *HandshakeMsg, regis
}

// Check if we have an outgoing request to this peer (mutual handshake)
if _, ok := hm.outgoing[peerNodeID]; ok {
// Mutual! Auto-approve
// SEC-038: mutual auto-trust is gated on registryBound so a peer
// cannot claim any NodeID with their own keypair and slip into trust.
if _, ok := hm.outgoing[peerNodeID]; ok && registryBound {
// Mutual! Auto-approve (registry confirmed pubkey binding)
delete(hm.outgoing, peerNodeID)
hm.markTrustedLocked(peerNodeID, &TrustRecord{
NodeID: peerNodeID,
Expand All @@ -652,7 +654,9 @@ func (hm *Manager) handleRequest(stream coreapi.Stream, msg *HandshakeMsg, regis
}

// Check if peers are on the same network (network trust)
if hm.sameNetwork(peerNodeID) {
// SEC-038: same-network auto-trust is gated on registryBound so a
// peer cannot claim any NodeID with their own keypair and slip into trust.
if hm.sameNetwork(peerNodeID) && registryBound {
hm.markTrustedLocked(peerNodeID, &TrustRecord{
NodeID: peerNodeID,
PublicKey: msg.PublicKey,
Expand Down
2 changes: 1 addition & 1 deletion zz_ceiling_more_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestHandleRequest_SameNetworkDirectPathAutoApproves(t *testing.T) {
NodeID: 99,
PublicKey: "peer-99-key",
Timestamp: time.Now().Unix(),
}, false)
}, true) // registryBound=true: peer's pubkey was confirmed by the registry

hm.mu.RLock()
rec, trusted := hm.trusted[99]
Expand Down
2 changes: 1 addition & 1 deletion zz_handshake_accept_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestHandleRequestMutualAutoApprovesAndMarksMutual(t *testing.T) {
PublicKey: "peer-99-key",
Timestamp: time.Now().Unix(),
}
hm.handleRequest(nil, msg, false)
hm.handleRequest(nil, msg, true) // registryBound=true: peer is verified by registry

hm.mu.RLock()
rec, ok := hm.trusted[99]
Expand Down
Loading