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 signed manual update bootstraps on HTTPS

pulse-triage[bot]89c61b233c12
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 1a9787a6b2..99a16bc347 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -15,6 +15,25 @@
```
## Purpose
+### Manual bootstrap transport remains HTTPS-only
+
+The generated manual update helper restricts curl's initial protocol and every
+redirect to HTTPS for both the installer and its detached signature. The
+existing disabled ambient curl configuration, connection/total deadlines,
+private temporary files and pinned SSH signature verification remain required.
+A download or protocol refusal stops before installer execution, removes owned
+bootstrap inputs and cannot report a completed update. HTTPS asset redirects
+remain supported; transport authentication does not replace signature checks.
+
+`TestRootManualUpdateHTTPSOnly` executes the emitted helper with real curl,
+locally authenticated TLS and a real fixture SSH signature. Its initial-HTTP
+and installer/signature downgrade controls require zero plaintext requests,
+while direct and redirected HTTPS deliver the signed installer and exact
+arguments. Existing deadline, invalid-signature, allocation and cleanup controls
+remain mandatory. The native systemd recipe's closed transport adapter admits
+only the new exact envelope. These offline transport controls are not signed
+published-artifact, native systemd or original LXC recovery acceptance.
+
### Manual update helpers retain the running reader
`install.sh setup_update_command` stages the manual update helper beside its
diff --git a/install.sh b/install.sh
index 2d39567470..ed9118a016 100644
--- a/install.sh
+++ b/install.sh
@@ -4368,11 +4368,13 @@ tmp_installer=\$(mktemp /tmp/pulse-update-installer.XXXXXX)
tmp_signature=\$(mktemp /tmp/pulse-update-installer.sig.XXXXXX)
# Do not let ambient curl retries or a stalled bootstrap hold update forever.
# No installer/service change is allowed until both bounded downloads verify.
-if ! curl -q -fsSL --connect-timeout 10 --max-time 60 "\$INSTALLER_URL" -o "\$tmp_installer"; then
+# Keep both the initial request and GitHub's asset redirects on authenticated
+# HTTPS. A signature check is not permission to downgrade the transport.
+if ! curl -q -fsSL --connect-timeout 10 --max-time 60 --proto '=https' --proto-redir '=https' "\$INSTALLER_URL" -o "\$tmp_installer"; then
echo "Failed to download Pulse installer from \$INSTALLER_URL" >&2
exit 1
fi
-if ! curl -q -fsSL --connect-timeout 10 --max-time 60 "\$INSTALLER_SIG_URL" -o "\$tmp_signature"; then
+if ! curl -q -fsSL --connect-timeout 10 --max-time 60 --proto '=https' --proto-redir '=https' "\$INSTALLER_SIG_URL" -o "\$tmp_signature"; then
echo "Failed to download Pulse installer signature from \$INSTALLER_SIG_URL" >&2
exit 1
fi
diff --git a/scripts/installtests/auto_update_systemd.py b/scripts/installtests/auto_update_systemd.py
index f4aca331e5..454c50fb74 100644
--- a/scripts/installtests/auto_update_systemd.py
+++ b/scripts/installtests/auto_update_systemd.py
@@ -65,7 +65,8 @@ if pathlib.Path(sys.argv[0]).name == "mktemp":
# arbitrary curl option parser. The short form is used by isolated controls.
flags = ["--disable", "-fsSL", "--connect-timeout", "5", "--max-time", "60",
"--proto", "=https", "--proto-redir", "=https"]
-manual_flags = ["-q", "-fsSL", "--connect-timeout", "10", "--max-time", "60"]
+manual_flags = ["-q", "-fsSL", "--connect-timeout", "10", "--max-time", "60",
+ "--proto", "=https", "--proto-redir", "=https"]
if args[:len(flags)] == flags:
args = args[len(flags):]
elif args[:len(manual_flags)] == manual_flags:
diff --git a/scripts/installtests/root_install_sh_test.go b/scripts/installtests/root_install_sh_test.go
index 86becea69b..edbf487df7 100644
--- a/scripts/installtests/root_install_sh_test.go
+++ b/scripts/installtests/root_install_sh_test.go
@@ -2,13 +2,17 @@ package installtests
import (
"context"
+ "encoding/pem"
"io"
+ "net/http"
+ "net/http/httptest"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
+ "sync/atomic"
"testing"
"time"
)
@@ -2838,11 +2842,13 @@ exec /usr/bin/mktemp "$FIXTURE/temporary/input.XXXXXX"
"curl": `#!/bin/bash
set -eu
[[ "$1" == -q ]] || { echo 'ambient curl configuration is not disabled' >&2; exit 99; }
-url=""; dest=""; connect=""; maximum=""
+url=""; dest=""; connect=""; maximum=""; protocols=""; redirects=""
while [[ $# -gt 0 ]]; do
case "$1" in
--connect-timeout) connect="$2"; shift 2 ;;
--max-time) maximum="$2"; shift 2 ;;
+ --proto) protocols="$2"; shift 2 ;;
+ --proto-redir) redirects="$2"; shift 2 ;;
-o) dest="$2"; shift 2 ;;
-q|-fsSL) shift ;;
https://github.com/rcourtman/Pulse/releases/latest/download/install.sh*) url="$1"; shift ;;
@@ -2851,6 +2857,7 @@ while [[ $# -gt 0 ]]; do
done
printf '%s %s %s\n' "$url" "$connect" "$maximum" >> "$FIXTURE/transport"
[[ "$connect" == 10 && "$maximum" == 60 ]] || { echo 'missing bootstrap download deadline' >&2; exit 99; }
+[[ "$protocols" == =https && "$redirects" == =https ]] || { echo 'missing bootstrap HTTPS restriction' >&2; exit 99; }
case "$url" in
*.sshsig) phase=signature; source="$FIXTURE_ASSETS/install.sh.sig" ;;
*/install.sh) phase=installer; source="$FIXTURE_ASSETS/install.sh" ;;
@@ -2926,6 +2933,141 @@ fi
}
}
+// Exercise the emitted helper with real curl, TLS and SSH signatures. The
+// adapter changes only the two fixed GitHub URLs and the fixture CA, retaining
+// production options. No service, external host or installed binary is used.
+func TestRootManualUpdateHTTPSOnly(t *testing.T) {
+ curl, err := exec.LookPath("curl")
+ if err != nil {
+ t.Fatal("curl is required for the installer transport controls: ", err)
+ }
+ assets := t.TempDir()
+ key := filepath.Join(assets, "key")
+ installer := filepath.Join(assets, "installer")
+ const payload = "#!/bin/bash\nprintf '%s\\n' \"$@\" > \"$PUBLICATION_ROOT/executed\"\n"
+ if err := os.WriteFile(installer, []byte(payload), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ for _, args := range [][]string{
+ {"-q", "-t", "ed25519", "-N", "", "-f", key},
+ {"-q", "-Y", "sign", "-f", key, "-n", "pulse-install", installer},
+ } {
+ if out, err := exec.Command("ssh-keygen", args...).CombinedOutput(); err != nil {
+ t.Fatalf("fixture signing: %v\n%s", err, out)
+ }
+ }
+ publicKey, err := os.ReadFile(key + ".pub")
+ if err != nil {
+ t.Fatal(err)
+ }
+ signature, err := os.ReadFile(installer + ".sig")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, fault := range []string{"https", "https_redirect", "http_initial", "http_installer_redirect", "http_signature_redirect"} {
+ t.Run(fault, func(t *testing.T) {
+ dir, helper, env := manualUpdatePublicationFixture(t)
+ var plainRequests, tlsRequests atomic.Int32
+ serve := func(w http.ResponseWriter, r *http.Request) {
+ if strings.HasSuffix(r.URL.Path, "signature") {
+ _, _ = w.Write(signature)
+ } else {
+ _, _ = io.WriteString(w, payload)
+ }
+ }
+ plain := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ plainRequests.Add(1)
+ serve(w, r)
+ }))
+ defer plain.Close()
+ tls := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ tlsRequests.Add(1)
+ if (fault == "http_installer_redirect" && r.URL.Path == "/installer") ||
+ (fault == "http_signature_redirect" && r.URL.Path == "/signature") {
+ http.Redirect(w, r, plain.URL+r.URL.Path, http.StatusFound)
+ } else if fault == "https_redirect" && !strings.HasPrefix(r.URL.Path, "/cdn/") {
+ http.Redirect(w, r, "/cdn"+r.URL.Path, http.StatusFound)
+ } else {
+ serve(w, r)
+ }
+ }))
+ defer tls.Close()
+ ca := filepath.Join(dir, "fixture-ca.pem")
+ if err := os.WriteFile(ca, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: tls.Certificate().Raw}), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ tools := filepath.Join(dir, "tools")
+ if err := os.Mkdir(tools, 0o700); err != nil {
+ t.Fatal(err)
+ }
+ adapter := `#!/bin/bash
+set -euo pipefail
+[[ "$1" == -q ]] || exit 97
+shift
+args=()
+for arg in "$@"; do
+ case "$arg" in
+ https://github.com/rcourtman/Pulse/releases/latest/download/install.sh) arg="$FIXTURE_ORIGIN/installer" ;;
+ https://github.com/rcourtman/Pulse/releases/latest/download/install.sh.sshsig) arg="$FIXTURE_ORIGIN/signature" ;;
+ esac
+ args+=("$arg")
+done
+exec "$REAL_CURL" -q --cacert "$FIXTURE_CA" "${args[@]}"
+`
+ if err := os.WriteFile(filepath.Join(tools, "curl"), []byte(adapter), 0o700); err != nil {
+ t.Fatal(err)
+ }
+ // Keep every allocated bootstrap input private to this fixture and
+ // observable after success/refusal, including the signer's scratch.
+ if err := os.WriteFile(filepath.Join(tools, "mktemp"), []byte("#!/bin/bash\nexec /usr/bin/mktemp \"$PUBLICATION_ROOT/input.XXXXXX\"\n"), 0o700); err != nil {
+ t.Fatal(err)
+ }
+ origin := tls.URL
+ if fault == "http_initial" {
+ origin = plain.URL
+ }
+ env = append(env, "FIXTURE_PUBLIC_KEY="+strings.TrimSpace(string(publicKey)),
+ "FIXTURE_ORIGIN="+origin, "FIXTURE_CA="+ca, "REAL_CURL="+curl,
+ "PATH="+tools+string(os.PathListSeparator)+os.Getenv("PATH"),
+ "NO_PROXY=*", "no_proxy=*")
+ runManualUpdatePublication(t, env, `source "$PUBLICATION_SOURCE"
+PINNED_RELEASE_SSH_PUBLIC_KEY="$FIXTURE_PUBLIC_KEY"
+setup_update_command`)
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "bash", helper, "--version", "v0.0.1")
+ cmd.Env = env
+ out, runErr := cmd.CombinedOutput()
+ if ctx.Err() != nil {
+ t.Fatalf("fixture exceeded deadline: %v\n%s", ctx.Err(), out)
+ }
+ executed, executedErr := os.ReadFile(filepath.Join(dir, "executed"))
+ if strings.HasPrefix(fault, "https") {
+ wantTLS := int32(2)
+ if fault == "https_redirect" {
+ wantTLS = 4
+ }
+ if runErr != nil || executedErr != nil || string(executed) != "--version\nv0.0.1\n" || tlsRequests.Load() != wantTLS {
+ t.Errorf("authenticated HTTPS did not execute the signed installer once: %v, %v, %q, TLS=%d\n%s", runErr, executedErr, executed, tlsRequests.Load(), out)
+ }
+ } else {
+ if runErr == nil || !os.IsNotExist(executedErr) || strings.Contains(string(out), "Update complete!") {
+ t.Errorf("plaintext transport reached installer/success: %v, %v\n%s", runErr, executedErr, out)
+ }
+ if !strings.Contains(string(out), "Failed to download Pulse installer") {
+ t.Errorf("missing bootstrap refusal diagnostic: %s", out)
+ }
+ }
+ if plainRequests.Load() != 0 {
+ t.Errorf("sent %d unauthenticated HTTP requests", plainRequests.Load())
+ }
+ if litter, err := filepath.Glob(filepath.Join(dir, "input.*")); err != nil || len(litter) != 0 {
+ t.Errorf("bootstrap inputs survived: %v, %v", litter, err)
+ }
+ })
+ }
+}
+
// Only setup_update_command runs: no downloads, system services or installed
// application are involved. The override admits an exact parent-source control.
func manualUpdatePublicationFixture(t *testing.T) (string, string, []string) {
diff --git a/scripts/tests/test_auto_update_systemd.py b/scripts/tests/test_auto_update_systemd.py
index 4ca21ea7f7..9a4ddda335 100644
--- a/scripts/tests/test_auto_update_systemd.py
+++ b/scripts/tests/test_auto_update_systemd.py
@@ -179,11 +179,14 @@ class NativeContracts(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertEqual((root / "executed").read_text(), "--version\nv0.0.1\n")
self.assertEqual(list((root / "tmp").iterdir()), [])
- flags = ["-q", "-fsSL", "--connect-timeout", "10", "--max-time", "60"]
+ flags = ["-q", "-fsSL", "--connect-timeout", "10", "--max-time", "60",
+ "--proto", "=https", "--proto-redir", "=https"]
url = "https://github.com/rcourtman/Pulse/releases/latest/download/install.sh"
for changed in (flags[1:], [*flags, "--insecure"], [*flags, "--retry", "3"],
[arg if arg != "60" else "61" for arg in flags],
- [arg if arg != "10" else "11" for arg in flags]):
+ [arg if arg != "10" else "11" for arg in flags],
+ flags[:-4], flags[:-2],
+ [arg if arg != "=https" else "=all" for arg in flags]):
with self.subTest(flags=changed):
target = root / "refused"
result = subprocess.run([str(root / "tools/curl"), *changed, url, "-o", str(target)],