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.

Refuse installed executable drift during updater readback

pulse-triage[bot]4c75f03aa5e6
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 16e8d74dbd..ae226a6768 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -570,8 +570,12 @@ compares the selected executable with the actual Linux `/proc/MainPID/exe` bytes
Two complete, bounded observations of the exact unit's LoadState, ActiveState
and positive MainPID must surround that comparison and retain the same active
PID. Successful recovery of a previously active unit has the same requirement
-before releasing its rollback backup. Equivalent bytes at a custom or symlinked
-path are admitted; replacing an old process's on-disk path is not proof that
+before releasing its rollback backup. After the second manager read, the same
+selected installation path must still be a regular executable whose bytes match
+that process. An unchanged PID cannot hide a replaced, removed, non-executable
+or redirected destination during readback. This is a bounded readback fence,
+not an atomic lock against all later external writes. Equivalent bytes at a
+custom or symlinked path are admitted; replacing an old process's on-disk path is not proof that
that process uses the replacement. A broken primary executable never falls
back to an unrelated legacy file.
@@ -587,6 +591,10 @@ active, its actual running executable must be checked too.
restore refusal controls. `TestAutoUpdateRunningExecutableIdentity` requires
Linux owned-process byte/readback/deadline controls: they run a private
executable, atomically replace its path and inspect its real `/proc` entry.
+The final-read drift control changes primary, legacy and symlinked destinations
+during the second manager observation and requires uncertainty, while equal-byte
+atomic replacement remains accepted. It also checks that the selected mutation
+actually occurred; a failed fixture write cannot substitute for drift refusal.
They do not use a native manager or install Pulse. Existing signed/manager-double
matrices keep that distinction explicit. The containing hosted systemd recipe
supplies real-Pulse/source/native evidence; this source repair alone establishes
diff --git a/scripts/installtests/pulse_auto_update_test.go b/scripts/installtests/pulse_auto_update_test.go
index b4a80a07df..82f0405224 100644
--- a/scripts/installtests/pulse_auto_update_test.go
+++ b/scripts/installtests/pulse_auto_update_test.go
@@ -204,6 +204,7 @@ func TestAutoUpdateRunningExecutableIdentity(t *testing.T) {
for _, name := range []string{
"test_actual_process_not_replaced_disk_path_is_checked",
"test_complete_stable_main_pid_tuple_is_required",
+ "test_final_manager_read_cannot_hide_installed_executable_drift",
"test_manager_diagnostics_refuse_either_running_identity_read",
"test_identity_read_timeout_is_bounded_and_owned_process_is_reaped",
} {
diff --git a/scripts/pulse-auto-update.sh b/scripts/pulse-auto-update.sh
index 99bcc8fcc6..43c65bc696 100755
--- a/scripts/pulse-auto-update.sh
+++ b/scripts/pulse-auto-update.sh
@@ -500,6 +500,15 @@ verify_update_running_executable() {
log error "Running Pulse identity changed during verification ($service_name)" >&2
return 2
fi
+ # The final manager read does not keep the installation path stable. A
+ # concurrent replacement/removal can leave the same process active while
+ # the next start would use different or unusable bytes. Recheck the same
+ # selected path after that read; uncertainty still grants no recovery.
+ if [[ ! -f "$binary" || ! -x "$binary" ]] ||
+ ! timeout -k 1 5 cmp -s -- "$binary" "/proc/$after_pid/exe"; then
+ log error "Installed Pulse executable changed during verification ($service_name)" >&2
+ return 2
+ fi
return 0
}
diff --git a/scripts/tests/test_auto_update_service_state.py b/scripts/tests/test_auto_update_service_state.py
index d0aecdd43f..ca47cc21f1 100644
--- a/scripts/tests/test_auto_update_service_state.py
+++ b/scripts/tests/test_auto_update_service_state.py
@@ -633,7 +633,7 @@ class UpdateServiceState(UpdaterFixture):
PROCESS_MANAGER = r'''#!/usr/bin/env python3
-import os, sys, time
+import os, shutil, sys, time
from pathlib import Path
f = Path(os.environ["FIXTURE"])
args = sys.argv[1:]
@@ -644,6 +644,24 @@ count = int((f / "observations").read_text()) + 1 if (f / "observations").exists
mode = os.environ["IDENTITY_MODE"]
if mode == "error": sys.exit(1)
if mode == "hang": time.sleep(30)
+if mode.startswith("disk-drift:") and count == 2:
+ installed = Path(os.environ["SELECTED_BINARY"])
+ fault = mode.partition(":")[2]
+ if fault in ("different", "same-copy"):
+ replacement = f / "drift-replacement"
+ shutil.copyfile("/bin/sleep" if fault == "different" else sys.executable, replacement)
+ replacement.chmod(0o700)
+ replacement.replace(installed)
+ elif fault == "nonexecutable": installed.chmod(0o600)
+ elif fault == "missing": installed.unlink()
+ elif fault == "wrong-symlink":
+ installed.unlink()
+ installed.symlink_to("/bin/sleep")
+ elif fault == "directory":
+ installed.unlink()
+ installed.mkdir()
+ else: sys.exit(97)
+ (f / "identity-drift-applied").write_text(fault)
pid = os.environ["OWNED_PID"]
if mode == "pid-zero": pid = "0"
if mode == "pid-negative": pid = "-1"
@@ -702,12 +720,15 @@ class RunningExecutable(unittest.TestCase):
env = dict(os.environ, FIXTURE=str(f), UPDATER=str(UPDATER),
PULSE_INSTALL_DIR=str(f / "install"), OWNED_PID=str(child.pid),
DIFFERENT_PID=str(os.getpid()), IDENTITY_MODE=mode,
+ SELECTED_BINARY=str(f / "install/pulse" if binary_mode == "legacy" else installed),
PATH=str(f / "tools") + os.pathsep + os.environ["PATH"])
script = ('set -euo pipefail\nsource "$UPDATER"\nlog() { :; }\n'
'status=0\nverify_update_running_executable pulse-custom@department || status=$?\n'
'printf "IDENTITY_STATUS=%s\\n" "$status"\nexit "$status"\n')
started = time.monotonic()
r = subprocess.run(["bash", "-c", script], env=env, capture_output=True, timeout=10)
+ if mode.startswith("disk-drift:"):
+ self.assertEqual((f / "identity-drift-applied").read_text(), mode.partition(":")[2])
return r, time.monotonic() - started, int((f / "observations").read_text())
finally:
child.terminate()
@@ -732,6 +753,22 @@ class RunningExecutable(unittest.TestCase):
self.assertEqual(r.returncode, 0 if accepted else 2, r.stderr)
self.assertEqual(observations, 2 if accepted or mode in ("pid-moved", "state-moved") else 1)
+ def test_final_manager_read_cannot_hide_installed_executable_drift(self):
+ # The first real /proc comparison succeeds. Change only the selected
+ # installation path during the second manager read, leaving the owned
+ # process/PID active. Equal-byte atomic replacement remains supported.
+ for binary in ("same", "legacy", "symlink"):
+ for fault in ("different", "nonexecutable", "missing", "wrong-symlink", "directory", "same-copy"):
+ # Never chmod the shared interpreter behind a symlink.
+ if binary == "symlink" and fault == "nonexecutable":
+ continue
+ with self.subTest(binary=binary, fault=fault):
+ result, _, observations = self.run_identity(mode="disk-drift:" + fault, binary_mode=binary)
+ expected = 0 if fault == "same-copy" else 2
+ self.assertEqual(result.returncode, expected, result.stderr)
+ self.assertIn(f"IDENTITY_STATUS={expected}".encode(), result.stdout)
+ self.assertEqual(observations, 2)
+
def test_manager_diagnostics_refuse_either_running_identity_read(self):
# These read the actual private child's /proc executable before and
# after the unchanged byte comparison, not a simulated version file.