Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Distinguish unknown member trust from explicit CA validation

pulse-triage[bot]f468b24fc4c4
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 84dba9f6b9..f4e8a67daf 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -32,7 +32,9 @@ reconciles that exact endpoint in polling trust. Candidate PVE configuration
is published in memory only after persistence succeeds.
Cluster member responses expose the permitted runtime `tlsEndpoint` and
-`usesPrimaryTLS`, with the effective fingerprint. Saved-credential Test accepts
+`usesPrimaryTLS`, with the effective fingerprint. `tlsFirstUse` distinguishes
+an unknown member from an explicit empty-pin choice, so the editor does not
+claim that automatic first-use trust is saved CA validation. Saved-credential Test accepts
an optional existing PVE `endpoint` and temporary TLS edits. It makes no saved
trust or health changes and states that other endpoints/background collection
were not tested. Omitted TLS edits use polling's saved trust, including an
diff --git a/internal/api/configapi/config_handlers.go b/internal/api/configapi/config_handlers.go
index c6c99b2be1..33307f1be0 100644
--- a/internal/api/configapi/config_handlers.go
+++ b/internal/api/configapi/config_handlers.go
@@ -959,6 +959,7 @@ type ClusterEndpointResponse struct {
IPOverride string `json:"ipOverride,omitempty"`
TLSEndpoint string `json:"tlsEndpoint,omitempty"`
UsesPrimaryTLS bool `json:"usesPrimaryTLS,omitempty"`
+ TLSFirstUse bool `json:"tlsFirstUse,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Online bool `json:"online"`
LastSeen time.Time `json:"lastSeen,omitempty"`
diff --git a/internal/api/configapi/config_handlers_connection_test.go b/internal/api/configapi/config_handlers_connection_test.go
index cbf2416fda..573db58811 100644
--- a/internal/api/configapi/config_handlers_connection_test.go
+++ b/internal/api/configapi/config_handlers_connection_test.go
@@ -373,6 +373,20 @@ func TestPVEEndpointTrustSavedPolling(t *testing.T) {
pin := func(c tls.Certificate) string { return fmt.Sprintf("%x", sha256.Sum256(c.Certificate[0])) }
old := [2]tls.Certificate{makeLeaf(2), makeLeaf(3)}
renewed := [2]tls.Certificate{makeLeaf(4), makeLeaf(5)}
+ makeUntrusted := func(serial int64) tls.Certificate {
+ pub, key, err := ed25519.GenerateKey(rand.Reader)
+ if err != nil {
+ t.Fatal(err)
+ }
+ leaf := &x509.Certificate{SerialNumber: big.NewInt(serial), NotBefore: time.Now().Add(-time.Hour), NotAfter: time.Now().Add(time.Hour), IPAddresses: []net.IP{net.ParseIP("127.0.0.1")}, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, KeyUsage: x509.KeyUsageDigitalSignature}
+ der, err := x509.CreateCertificate(rand.Reader, leaf, leaf, pub, key)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return tls.Certificate{Certificate: [][]byte{der}, PrivateKey: key}
+ }
+ untrusted := [2]tls.Certificate{makeUntrusted(6), makeUntrusted(7)}
+
var active [2]atomic.Pointer[tls.Certificate]
var authenticated [2]atomic.Int32
var servers [2]*httptest.Server
@@ -424,12 +438,15 @@ func TestPVEEndpointTrustSavedPolling(t *testing.T) {
{"primary-CA-clear-is-scoped", "primary-ca", false, [2]bool{true, false}, 200},
{"explicit-both-pins", "both-pins", false, [2]bool{true, true}, 200},
{"explicit-both-CA", "both-ca", false, [2]bool{true, true}, 200},
+ {"CA-mode-rejects-untrusted-leaves", "both-ca-untrusted", false, [2]bool{false, false}, 400},
{"member-CA-does-not-inherit-primary-pin", "member-ca", false, [2]bool{true, true}, 200},
{"original-leaves-control", "", true, [2]bool{true, true}, 200},
} {
t.Run(tc.name, func(t *testing.T) {
for i, s := range servers {
- if tc.original {
+ if tc.action == "both-ca-untrusted" {
+ active[i].Store(&untrusted[i])
+ } else if tc.original {
active[i].Store(&old[i])
} else {
active[i].Store(&renewed[i])
@@ -582,3 +599,24 @@ func TestPVEEndpointTrustAdmission(t *testing.T) {
t.Fatalf("failed save published trust: %d %s", rec.Code, rec.Body.String())
}
}
+
+func TestPVEEndpointUnknownTrustProjection(t *testing.T) {
+ instance := config.PVEInstance{Host: "https://primary.test:8006", Fingerprint: "primary-pin", VerifySSL: true, ClusterEndpoints: []config.ClusterEndpoint{{NodeName: "peer", Host: "https://peer.test:8006"}}}
+ projected := pveClusterEndpointTLSResponses(instance, config.DiscoveryConfig{})
+ if len(projected) != 1 || !projected[0].TLSFirstUse {
+ t.Fatal("unknown first-use member was described as CA policy")
+ }
+ empty := ""
+ updated, err := applyPVEEndpointTrustUpdates(instance, NodeConfigRequest{ClusterEndpointTrustOverrides: []ClusterEndpointTrustOverrideRequest{{Endpoint: projected[0].TLSEndpoint, Fingerprint: &empty}}}, config.DiscoveryConfig{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ projected = pveClusterEndpointTLSResponses(updated, config.DiscoveryConfig{})
+ if projected[0].TLSFirstUse || projected[0].Fingerprint != "" {
+ t.Fatal("explicit CA policy was described as first-use trust")
+ }
+ _, fingerprint, err := pveConnectionTestTrust(updated, nodeConnectionTestTLSOptions{Endpoint: projected[0].TLSEndpoint}, config.DiscoveryConfig{})
+ if err != nil || fingerprint != "" {
+ t.Fatal("saved probe discarded explicit member CA policy")
+ }
+}
diff --git a/internal/api/configapi/config_node_tls.go b/internal/api/configapi/config_node_tls.go
index a1d5c6fea2..596ec15692 100644
--- a/internal/api/configapi/config_node_tls.go
+++ b/internal/api/configapi/config_node_tls.go
@@ -112,6 +112,7 @@ func pveClusterEndpointTLSResponses(instance config.PVEInstance, discovery confi
key, valid := proxmox.ClusterEndpointIdentity(target)
responses[i].UsesPrimaryTLS = valid && primaryValid && key == primary
fingerprint, known, err := proxmox.ResolveEndpointFingerprint(target, pins, conflicts...)
+ responses[i].TLSFirstUse = !known && instance.Fingerprint != "" && !responses[i].UsesPrimaryTLS
if err == nil && known {
responses[i].Fingerprint = fingerprint
}