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.

Compile out release env guardrail bypasses

rcourtman360d08104eca
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 366b6db125..3c9fd7d2d4 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -731,6 +731,11 @@ handoff stays on one canonical local redirect builder. Lifecycle-adjacent setup
and hosted bootstrap surfaces may depend on shared OIDC/SAML callbacks, but
they must not reintroduce per-handler `returnTo` shaping that can bypass the
governed local-path validation before success or error query markers are added.
+That same shared auth dependency also assumes release builds do not revive the
+development-only admin bypass path. Lifecycle-adjacent setup or first-session
+flows may still run in non-release developer mode with `ALLOW_ADMIN_BYPASS`,
+but release binaries must compile that env override out instead of carrying a
+runtime branch that can be reopened after deployment.
Agent lifecycle owns the install/register/update continuity surfaces, but it
does not own unified-resource history or control-plane timeline persistence.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index d168b9852e..047f90b1c6 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -218,6 +218,11 @@ the canonical monitored-system blocked payload.
canonical invitation, membership-management, or explicit owner-transfer flows may create tenant membership or
change the stored owner/admin role. Shared auth routes and downstream settings consumers must treat handoff role
claims as bounded by the server-owned membership record, never as authority to elevate tenant privileges.
+ The same shared auth boundary also owns release-build admin bypass gating.
+ `internal/api/auth.go` may keep `ALLOW_ADMIN_BYPASS` for non-release
+ development workflows, but release builds must compile that env override
+ out entirely instead of reading it and deciding at runtime whether to
+ honor or ignore it.
20. Keep mobile onboarding payload reads aligned with the server-owned relay-mobile credential: `internal/api/router_routes_ai_relay.go`, `internal/api/onboarding_handlers.go`, and `internal/api/contract_test.go` must allow the dedicated `relay:mobile:access` scope to reach the governed QR, deep-link, and connection-validation payloads without reintroducing a broader `settings:read` requirement for token-authenticated pairing clients.
That same shared relay/runtime boundary also owns hostname target
equivalence for agent command routing. `internal/api/router_routes_ai_relay.go`
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 34857dcc66..65a6a0d212 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -88,6 +88,8 @@ agreement, and cloud-specific enforcement rules.
66. `pulse-pro:scripts/grandfathered_recurring_cutover_preview.py`
67. `pulse-pro:scripts/validate_public_pricing_model.py`
68. `pulse-pro:V6_LAUNCH_CHECKLIST.md`
+69. `pkg/licensing/trial_activation_public_key_override_dev.go`
+70. `pkg/licensing/trial_activation_public_key_override_release.go`
## Shared Boundaries
@@ -256,6 +258,14 @@ Community limit enforcement.
Patrol`, `Pulse Alert Analysis`, `Patrol Auto-Fix`, and `Kubernetes
Insights`, rather than reviving generic `AI Patrol` or `AI ... analysis`
branding inside self-hosted pricing surfaces.
+26. Keep hosted trial-activation verifier source selection compile-time owned.
+ `pkg/licensing/trial_activation.go`,
+ `pkg/licensing/trial_activation_public_key_override_dev.go`, and
+ `pkg/licensing/trial_activation_public_key_override_release.go` together
+ define whether runtime environment may override the hosted verifier. Dev
+ builds may keep the local override path, but release builds must resolve
+ the verifier from the embedded build-time source of truth instead of
+ honoring `PULSE_HOSTED_MODE` or other runtime wiring.
## Forbidden Paths
@@ -1453,12 +1463,12 @@ tenant falls back to provider defaults, the persisted model identifier must
remain canonical `provider:model` data rather than a bare provider-local alias,
so hosted enterprise runtime startup does not fail before chat or approvals can
initialize.
-Hosted release builds must also accept the trial-activation public key from
-runtime environment when `PULSE_HOSTED_MODE=true`, because hosted tenants
-receive that verification key from control-plane deployment rather than from
-the embedded self-hosted release asset. Otherwise a hosted tenant can mount a
-valid lease and still fail its first hosted trial-activation verification path
-solely because the release binary refuses the deployed public-key source.
+Hosted release builds must not reopen the trial-activation public key through
+runtime environment just because `PULSE_HOSTED_MODE=true`. Managed tenants may
+still receive a hosted-specific verification key, but the release binary must
+consume that key through the build-time embedded source of truth rather than a
+runtime env override that can silently replace the trusted verifier after
+deployment.
Legacy MSP plan aliases are input-only compatibility shims. Live runtime
defaults, fallback provisioning, entitlement issuance, and limit/workspace
lookups must resolve to canonical `msp_starter` rather than preserving
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 1df19e581a..21b7041e85 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2100,7 +2100,9 @@
"label": "hosted trial activation proof",
"match_prefixes": [],
"match_files": [
- "pkg/licensing/trial_activation.go"
+ "pkg/licensing/trial_activation.go",
+ "pkg/licensing/trial_activation_public_key_override_dev.go",
+ "pkg/licensing/trial_activation_public_key_override_release.go"
],
"allow_same_subsystem_tests": false,
"test_prefixes": [],
diff --git a/internal/api/admin_bypass_mode_dev.go b/internal/api/admin_bypass_mode_dev.go
new file mode 100644
index 0000000000..e431f20d1e
--- /dev/null
+++ b/internal/api/admin_bypass_mode_dev.go
@@ -0,0 +1,18 @@
+//go:build !release
+
+package api
+
+import (
+ "os"
+ "strings"
+)
+
+func resolveAdminBypassEnv() (enabled, declined bool) {
+ if os.Getenv("ALLOW_ADMIN_BYPASS") != "1" {
+ return false, false
+ }
+ if os.Getenv("PULSE_DEV") == "true" || strings.EqualFold(os.Getenv("NODE_ENV"), "development") {
+ return true, false
+ }
+ return false, true
+}
diff --git a/internal/api/admin_bypass_mode_release.go b/internal/api/admin_bypass_mode_release.go
new file mode 100644
index 0000000000..eb2aaf79a5
--- /dev/null
+++ b/internal/api/admin_bypass_mode_release.go
@@ -0,0 +1,7 @@
+//go:build release
+
+package api
+
+func resolveAdminBypassEnv() (enabled, declined bool) {
+ return false, false
+}
diff --git a/internal/api/admin_bypass_release_test.go b/internal/api/admin_bypass_release_test.go
new file mode 100644
index 0000000000..852aadd912
--- /dev/null
+++ b/internal/api/admin_bypass_release_test.go
@@ -0,0 +1,19 @@
+//go:build release
+
+package api
+
+import "testing"
+
+func TestAdminBypassEnabled_IgnoredInReleaseBuild(t *testing.T) {
+ t.Setenv("ALLOW_ADMIN_BYPASS", "1")
+ t.Setenv("PULSE_DEV", "true")
+ t.Setenv("NODE_ENV", "development")
+ resetAdminBypassState()
+
+ if adminBypassEnabled() {
+ t.Fatal("adminBypassEnabled() should remain false in release builds")
+ }
+ if adminBypassState.declined {
+ t.Fatal("release builds should not treat ALLOW_ADMIN_BYPASS as a runtime path")
+ }
+}
diff --git a/internal/api/auth.go b/internal/api/auth.go
index 54e3469ce1..b35135cf4b 100644
--- a/internal/api/auth.go
+++ b/internal/api/auth.go
@@ -9,7 +9,6 @@ import (
"encoding/json"
"fmt"
"net/http"
- "os"
"strings"
"sync"
"time"
@@ -1231,18 +1230,14 @@ func getAPITokenRecordFromRequest(r *http.Request) *config.APITokenRecord {
}
func adminBypassEnabled() bool {
adminBypassState.once.Do(func() {
- if os.Getenv("ALLOW_ADMIN_BYPASS") != "1" {
- return
- }
-
- if os.Getenv("PULSE_DEV") == "true" || strings.EqualFold(os.Getenv("NODE_ENV"), "development") {
+ adminBypassState.enabled, adminBypassState.declined = resolveAdminBypassEnv()
+ if adminBypassState.enabled {
log.Warn().Msg("Admin authentication bypass ENABLED (development mode)")
- adminBypassState.enabled = true
return
}
-
- log.Warn().Msg("Ignoring ALLOW_ADMIN_BYPASS outside development mode")
- adminBypassState.declined = true
+ if adminBypassState.declined {
+ log.Warn().Msg("Ignoring ALLOW_ADMIN_BYPASS outside development mode")
+ }
})
return adminBypassState.enabled
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index cba280dea6..101714af88 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -10026,6 +10026,17 @@ func TestContract_AgentExecWebSocketAcceptsLegacyHostnameBinding(t *testing.T) {
}
}
+func TestContract_AdminBypassFailsClosedOutsideDevMode(t *testing.T) {
+ t.Setenv("ALLOW_ADMIN_BYPASS", "1")
+ t.Setenv("PULSE_DEV", "")
+ t.Setenv("NODE_ENV", "production")
+ resetAdminBypassState()
+
+ if adminBypassEnabled() {
+ t.Fatal("expected admin bypass to fail closed outside development mode")
+ }
+}
+
func TestContract_ResourceRelationshipsJSONSnapshot(t *testing.T) {
now := time.Date(2026, 3, 18, 17, 0, 0, 0, time.UTC)
payload := struct {
diff --git a/pkg/licensing/trial_activation.go b/pkg/licensing/trial_activation.go
index b7d6f3db52..70ee97441d 100644
--- a/pkg/licensing/trial_activation.go
+++ b/pkg/licensing/trial_activation.go
@@ -76,9 +76,9 @@ func DecodeEd25519PrivateKey(encoded string) (ed25519.PrivateKey, error) {
}
// TrialActivationPublicKey resolves the verification key for hosted trial
-// activation tokens. Environment override is only allowed in local/dev builds,
-// or in hosted mode where the control plane injects the verification key at
-// runtime for managed tenants.
+// activation tokens. Environment override is only allowed in local/dev builds.
+// Release builds must use the build-time embedded verification key instead of
+// reopening that trust boundary through hosted-mode environment wiring.
func TrialActivationPublicKey() (ed25519.PublicKey, error) {
if allowTrialActivationPublicKeyEnvOverride() {
if env := strings.TrimSpace(os.Getenv(TrialActivationPublicKeyEnvVar)); env != "" {
@@ -102,10 +102,7 @@ func TrialActivationPublicKey() (ed25519.PublicKey, error) {
}
func allowTrialActivationPublicKeyEnvOverride() bool {
- if allowPublicKeyEnvOverride() {
- return true
- }
- return strings.EqualFold(strings.TrimSpace(os.Getenv("PULSE_HOSTED_MODE")), "true")
+ return allowPublicKeyEnvOverride() || allowHostedTrialActivationPublicKeyEnvOverride()
}
// SignTrialActivationToken signs a hosted trial activation JWT.
diff --git a/pkg/licensing/trial_activation_public_key_override_dev.go b/pkg/licensing/trial_activation_public_key_override_dev.go
new file mode 100644
index 0000000000..738d39db27
--- /dev/null
+++ b/pkg/licensing/trial_activation_public_key_override_dev.go
@@ -0,0 +1,12 @@
+//go:build !release
+
+package licensing
+
+import (
+ "os"
+ "strings"
+)
+
+func allowHostedTrialActivationPublicKeyEnvOverride() bool {
+ return strings.EqualFold(strings.TrimSpace(os.Getenv("PULSE_HOSTED_MODE")), "true")
+}
diff --git a/pkg/licensing/trial_activation_public_key_override_release.go b/pkg/licensing/trial_activation_public_key_override_release.go
new file mode 100644
index 0000000000..020678084a
--- /dev/null
+++ b/pkg/licensing/trial_activation_public_key_override_release.go
@@ -0,0 +1,7 @@
+//go:build release
+
+package licensing
+
+func allowHostedTrialActivationPublicKeyEnvOverride() bool {
+ return false
+}
diff --git a/pkg/licensing/trial_activation_release_test.go b/pkg/licensing/trial_activation_release_test.go
index c653b7b434..3fd157b2d8 100644
--- a/pkg/licensing/trial_activation_release_test.go
+++ b/pkg/licensing/trial_activation_release_test.go
@@ -8,7 +8,7 @@ import (
"testing"
)
-func TestTrialActivationPublicKey_EnvOverrideHostedModeRelease(t *testing.T) {
+func TestTrialActivationPublicKey_EnvOverrideHostedModeReleaseRejected(t *testing.T) {
publicKey, _, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatalf("GenerateKey: %v", err)
@@ -16,12 +16,9 @@ func TestTrialActivationPublicKey_EnvOverrideHostedModeRelease(t *testing.T) {
t.Setenv("PULSE_HOSTED_MODE", "true")
t.Setenv(TrialActivationPublicKeyEnvVar, base64.StdEncoding.EncodeToString(publicKey))
- got, err := TrialActivationPublicKey()
- if err != nil {
- t.Fatalf("TrialActivationPublicKey: %v", err)
- }
- if string(got) != string(publicKey) {
- t.Fatal("public key mismatch")
+ _, err = TrialActivationPublicKey()
+ if err != ErrTrialActivationPublicKeyMissing {
+ t.Fatalf("TrialActivationPublicKey error = %v, want %v", err, ErrTrialActivationPublicKeyMissing)
}
}
diff --git a/pkg/licensing/trial_activation_test.go b/pkg/licensing/trial_activation_test.go
index e6e60b611e..9b6046e4ff 100644
--- a/pkg/licensing/trial_activation_test.go
+++ b/pkg/licensing/trial_activation_test.go
@@ -1,6 +1,7 @@
package licensing
import (
+ "bytes"
"crypto/ed25519"
"encoding/base64"
"errors"
@@ -165,29 +166,31 @@ func TestSignTrialActivationToken_RequiresReturnURL(t *testing.T) {
}
}
-func TestTrialActivationPublicKey_EnvOverride(t *testing.T) {
- pub, _, err := ed25519.GenerateKey(nil)
+func TestTrialActivationPublicKey_SelectsAllowedVerificationSource(t *testing.T) {
+ envPub, _, err := ed25519.GenerateKey(nil)
+ if err != nil {
+ t.Fatalf("GenerateKey: %v", err)
+ }
+ embeddedPub, _, err := ed25519.GenerateKey(nil)
if err != nil {
t.Fatalf("GenerateKey: %v", err)
}
- t.Setenv(TrialActivationPublicKeyEnvVar, base64.StdEncoding.EncodeToString(pub))
+ t.Setenv("PULSE_HOSTED_MODE", "true")
+ t.Setenv(TrialActivationPublicKeyEnvVar, base64.StdEncoding.EncodeToString(envPub))
embeddedBefore := EmbeddedPublicKey
t.Cleanup(func() { EmbeddedPublicKey = embeddedBefore })
- EmbeddedPublicKey = ""
+ EmbeddedPublicKey = base64.StdEncoding.EncodeToString(embeddedPub)
got, err := TrialActivationPublicKey()
if err != nil {
t.Fatalf("TrialActivationPublicKey: %v", err)
}
- if string(got) != string(pub) {
- t.Fatalf("TrialActivationPublicKey mismatch")
+ want := embeddedPub
+ if allowTrialActivationPublicKeyEnvOverride() {
+ want = envPub
}
-}
-
-func TestAllowTrialActivationPublicKeyEnvOverride_HostedMode(t *testing.T) {
- t.Setenv("PULSE_HOSTED_MODE", "true")
- if !allowTrialActivationPublicKeyEnvOverride() {
- t.Fatal("allowTrialActivationPublicKeyEnvOverride() = false, want true in hosted mode")
+ if !bytes.Equal(got, want) {
+ t.Fatalf("TrialActivationPublicKey mismatch")
}
}