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.

Keep bootstrap setup tokens out of logs

rcourtman178c07383003
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 879f3d7a00..070bde106d 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1110,7 +1110,10 @@ recovery: the supported operator path is `pulse bootstrap-token`, and the
runtime may not keep `.bootstrap_token` as an unstructured plaintext secret
file after startup. Canonical persistence must encrypt the bootstrap token at
rest and rewrite any legacy plaintext bootstrap-token file immediately into
-the encrypted canonical format on load.
+the encrypted canonical format on load. Automatic startup logs may surface the
+token file path for local recovery, but they must never print the bootstrap
+token value itself into stdout, systemd journal, Docker logs, or Kubernetes
+pod logs.
That same deploy/install runtime boundary also owns peer-node SSH trust.
`internal/hostagent/commands_deploy.go` must resolve and persist peer host
keys through the managed `ssh_known_hosts` store before any automated deploy
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 043cc29133..e75d046afa 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -577,7 +577,9 @@ the canonical monitored-system blocked payload.
the status payload flips `hasAuthentication` to `false`, preserves
`bootstrapTokenPath`, and allows browser-owned first-session proof to
re-enter the real setup wizard instead of silently falling back to an
- authenticated dashboard state.
+ authenticated dashboard state. That recovery transport may expose the
+ bootstrap token file path, but it must not emit the token value into
+ automatic runtime logs.
30. Keep shared SSO test and metadata-preview transport fail-closed: SAML
metadata URLs and OIDC issuer URLs must reject non-HTTP or userinfo-bearing
inputs before any outbound request is attempted, and OIDC discovery must
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index cfd5bd82b4..dee8040a39 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -592,6 +592,10 @@ forking separate row-local history reads or duplicate polling loops.
This subsystem now sits under the dedicated storage and recovery lane so the
operator-facing storage page, recovery timeline, and recovery-point persistence
engine stop hiding inside broader monitoring and E2E buckets.
+That same first-session recovery boundary also treats the bootstrap token as a
+local secret, not a log artifact. Storage and recovery surfaces may surface the
+bootstrap token file path when first-run auth is missing, but automatic runtime
+logs must never print the bootstrap token value itself.
Storage and recovery browser helpers now also keep one transport-tolerant
normalization edge. Recovery display models must accept legacy subject-label
fields and nullable mode/kind metadata before presenting canonical item labels,
@@ -2098,7 +2102,9 @@ That same shared dependency also assumes `/api/setup-script` keeps one
bootstrap token name end to end: embedded setup-script bootstrap uses the
canonical `setup_token` query and the rendered script body uses only
`PULSE_SETUP_TOKEN`, so adjacent setup and recovery-linked reruns do not drift
-across alias variables or deleted query naming.
+across alias variables or deleted query naming. That same recovery-linked
+bootstrap path may surface the local token file path, but it must not print
+the bootstrap token value itself into automatic runtime logs.
That same shared `internal/api/` dependency also assumes canonical /api/auto-register
responses keep `nodeId` on the resolved stored node identity after name
disambiguation, so adjacent setup and recovery-linked transport attachments do
diff --git a/internal/api/bootstrap_token.go b/internal/api/bootstrap_token.go
index 46c55990b6..0916df2579 100644
--- a/internal/api/bootstrap_token.go
+++ b/internal/api/bootstrap_token.go
@@ -58,16 +58,9 @@ func (r *Router) initializeBootstrapToken() {
r.bootstrapTokenPath = path
if created {
- // Display token prominently for easy discovery
- log.Warn().Msg("╔═══════════════════════════════════════════════════════════════════════╗")
- log.Warn().Msg("║ BOOTSTRAP TOKEN REQUIRED FOR FIRST-TIME SETUP ║")
- log.Warn().Msg("╠═══════════════════════════════════════════════════════════════════════╣")
- log.Warn().Msgf("║ Token: %-61s ║", token)
- log.Warn().Msgf("║ File: %-61s ║", path)
- log.Warn().Msg("╠═══════════════════════════════════════════════════════════════════════╣")
- log.Warn().Msg("║ Copy this token and paste it into the unlock screen in your browser. ║")
- log.Warn().Msg("║ This token will be automatically deleted after successful setup. ║")
- log.Warn().Msg("╚═══════════════════════════════════════════════════════════════════════╝")
+ log.Warn().
+ Str("token_path", path).
+ Msg("Bootstrap setup token created on disk; reveal it locally with `pulse bootstrap-token` or by reading the token file path")
} else {
log.Info().
Str("token_path", path).
diff --git a/internal/api/bootstrap_token_test.go b/internal/api/bootstrap_token_test.go
index 89e78ba2b8..e41542484b 100644
--- a/internal/api/bootstrap_token_test.go
+++ b/internal/api/bootstrap_token_test.go
@@ -1,6 +1,7 @@
package api
import (
+ "bytes"
"net/http"
"net/http/httptest"
"os"
@@ -11,6 +12,8 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/bootstrap"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
+ "github.com/rs/zerolog"
+ "github.com/rs/zerolog/log"
)
func TestLoadOrCreateBootstrapToken_EmptyDataPath(t *testing.T) {
@@ -424,6 +427,40 @@ func TestInitializeBootstrapToken_LoadOrCreateFails(t *testing.T) {
}
}
+func TestInitializeBootstrapToken_DoesNotLogSecretValue(t *testing.T) {
+ tmpDir := t.TempDir()
+ cfg := &config.Config{DataPath: tmpDir}
+ r := &Router{config: cfg}
+
+ var logBuf bytes.Buffer
+ origLogger := log.Logger
+ log.Logger = zerolog.New(&logBuf)
+ t.Cleanup(func() {
+ log.Logger = origLogger
+ })
+
+ r.initializeBootstrapToken()
+
+ token, created, tokenPath, err := loadOrCreateBootstrapToken(tmpDir)
+ if err != nil {
+ t.Fatalf("loadOrCreateBootstrapToken() error: %v", err)
+ }
+ if created {
+ t.Fatal("expected bootstrap token to already exist after initialization")
+ }
+
+ logOutput := logBuf.String()
+ if !strings.Contains(logOutput, tokenPath) {
+ t.Fatalf("expected bootstrap token log to include token path %q, got %q", tokenPath, logOutput)
+ }
+ if !strings.Contains(logOutput, "pulse bootstrap-token") {
+ t.Fatalf("expected bootstrap token log to mention local reveal command, got %q", logOutput)
+ }
+ if strings.Contains(logOutput, token) {
+ t.Fatalf("bootstrap token leaked into logs: %q", logOutput)
+ }
+}
+
func TestInitializeBootstrapToken_SSOEnabled(t *testing.T) {
tmpDir := t.TempDir()
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 8681cd99c6..04b954527b 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -47,6 +47,8 @@ import (
pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"
"github.com/rcourtman/pulse-go-rewrite/pkg/metrics"
"github.com/rcourtman/pulse-go-rewrite/pkg/reporting"
+ "github.com/rs/zerolog"
+ "github.com/rs/zerolog/log"
)
type resourceContractSnapshot struct {
@@ -8132,6 +8134,40 @@ func TestContract_BootstrapTokenPersistenceJSONSnapshot(t *testing.T) {
}
}
+func TestContract_InitializeBootstrapTokenLogsPathNotSecret(t *testing.T) {
+ tempDir := t.TempDir()
+ cfg := &config.Config{DataPath: tempDir}
+ router := &Router{config: cfg}
+
+ var logBuf bytes.Buffer
+ origLogger := log.Logger
+ log.Logger = zerolog.New(&logBuf)
+ t.Cleanup(func() {
+ log.Logger = origLogger
+ })
+
+ router.initializeBootstrapToken()
+
+ token, created, tokenPath, err := loadOrCreateBootstrapToken(tempDir)
+ if err != nil {
+ t.Fatalf("loadOrCreateBootstrapToken() error = %v", err)
+ }
+ if created {
+ t.Fatal("expected bootstrap token to already exist after initialization")
+ }
+
+ logOutput := logBuf.String()
+ if !strings.Contains(logOutput, tokenPath) {
+ t.Fatalf("bootstrap token log missing path %q in %q", tokenPath, logOutput)
+ }
+ if !strings.Contains(logOutput, "pulse bootstrap-token") {
+ t.Fatalf("bootstrap token log missing local reveal guidance: %q", logOutput)
+ }
+ if strings.Contains(logOutput, token) {
+ t.Fatalf("bootstrap token leaked into logs: %q", logOutput)
+ }
+}
+
func TestContract_QuickSecuritySetupBootstrapRetrievalGuidance(t *testing.T) {
resetPersistentAuthStoresForTests()
t.Cleanup(resetPersistentAuthStoresForTests)