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.

Harden CodeQL-scanned input boundaries

Pulse Test1720fd635b1c
diff --git a/.github/scripts/issue-version-triage.cjs b/.github/scripts/issue-version-triage.cjs
index 33b54e1f82..1c9a8215ed 100644
--- a/.github/scripts/issue-version-triage.cjs
+++ b/.github/scripts/issue-version-triage.cjs
@@ -29,12 +29,21 @@ function extractSectionValue(body, heading) {
return value || null;
}
+function stripHTMLComments(value) {
+ let stripped = String(value || "");
+ let previous;
+ do {
+ previous = stripped;
+ stripped = stripped.replace(/<!--[\s\S]*?(?:-->|$)/g, "");
+ } while (stripped !== previous);
+ return stripped;
+}
+
function classifyAdditionalActionableTopics(body) {
const value = extractSectionValue(body, "Additional actionable topics");
if (value === null) return null;
- const normalized = value
- .replace(/<!--([\s\S]*?)-->/g, "")
+ const normalized = stripHTMLComments(value)
.trim()
.toLowerCase()
.replace(/[.!]+$/g, "");
diff --git a/.github/scripts/issue-version-triage.test.cjs b/.github/scripts/issue-version-triage.test.cjs
index b230f7f281..6e061172b4 100644
--- a/.github/scripts/issue-version-triage.test.cjs
+++ b/.github/scripts/issue-version-triage.test.cjs
@@ -187,6 +187,12 @@ test("additional topic classification is explicit and fail-quiet for legacy form
classifyAdditionalActionableTopics("## Additional actionable topics\nNone known.\n"),
false
);
+ assert.equal(
+ classifyAdditionalActionableTopics(
+ "## Additional actionable topics\n<!<!-- -->-->\n"
+ ),
+ false
+ );
assert.equal(
classifyAdditionalActionableTopics(
"## Additional actionable topics\n- Add a storage filter\n- Reduce log noise\n"
diff --git a/cmd/pulse-agent-helper/main.go b/cmd/pulse-agent-helper/main.go
index 6140944798..21255162b3 100644
--- a/cmd/pulse-agent-helper/main.go
+++ b/cmd/pulse-agent-helper/main.go
@@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"log"
+ "math"
"net"
"os"
"os/signal"
@@ -146,7 +147,7 @@ func resolveIdentity(uidValue, gidValue int64) (uint32, int, error) {
}
gidValue = int64(parsed)
}
- if uidValue < 0 || gidValue < 0 || gidValue > int64(^uint(0)>>1) {
+ if uidValue < 0 || uidValue > math.MaxUint32 || gidValue < 0 || gidValue > math.MaxInt {
return 0, 0, errors.New("resolved UID or GID is invalid")
}
return uint32(uidValue), int(gidValue), nil
diff --git a/cmd/pulse-agent-helper/main_test.go b/cmd/pulse-agent-helper/main_test.go
index 01125f3501..de5b518b02 100644
--- a/cmd/pulse-agent-helper/main_test.go
+++ b/cmd/pulse-agent-helper/main_test.go
@@ -2,9 +2,11 @@ package main
import (
"encoding/json"
+ "math"
"os"
"path/filepath"
"runtime"
+ "strconv"
"strings"
"testing"
"time"
@@ -68,6 +70,17 @@ func TestResolveIdentityUsesExplicitNumericValues(t *testing.T) {
}
}
+func TestResolveIdentityRejectsOutOfRangeNumericValues(t *testing.T) {
+ if _, _, err := resolveIdentity(int64(^uint32(0))+1, 1002); err == nil {
+ t.Fatal("UID above uint32 accepted")
+ }
+ if strconv.IntSize == 32 {
+ if _, _, err := resolveIdentity(1001, int64(math.MaxInt32)+1); err == nil {
+ t.Fatal("GID above 32-bit int accepted")
+ }
+ }
+}
+
func TestInheritedSystemdListenerRejectsMalformedActivation(t *testing.T) {
t.Setenv("LISTEN_PID", "")
t.Setenv("LISTEN_FDS", "")
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 0e82d58a98..8f39fd8413 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -2745,6 +2745,17 @@ Agent` secondary handoff against the live setup wizard instead of relying
## Current State
+### Privileged helper framing and identities are architecture-safe
+
+The no-network helper rejects a framed allocation size that cannot include its
+four-byte protocol header before calling `make`, even if a future payload limit
+is raised beyond today's bounded request and response ceilings. Resolved helper
+UIDs must fit the protocol's unsigned 32-bit identity, and resolved socket GIDs
+must fit the target architecture's `int` before reaching `os.Chown`; this keeps
+the Linux 386 release target fail-closed instead of relying on a narrowing
+conversion. `TestCheckedFrameSizeRejectsInvalidAllocationSizes` and
+`TestResolveIdentityRejectsOutOfRangeNumericValues` pin those boundaries.
+
### Linked-agent interface precedence remains singular
A Proxmox node may now carry PVE API interface inventory alongside an optional
diff --git a/internal/agenthelper/protocol.go b/internal/agenthelper/protocol.go
index 504e9e99fc..b56dd313dc 100644
--- a/internal/agenthelper/protocol.go
+++ b/internal/agenthelper/protocol.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
+ "math"
)
const (
@@ -70,8 +71,17 @@ type frameError struct {
func (e *frameError) Error() string { return e.message }
+const frameHeaderBytes = 4
+
+func checkedFrameSize(payloadBytes int) (int, error) {
+ if payloadBytes < 0 || payloadBytes > math.MaxInt-frameHeaderBytes {
+ return 0, &frameError{message: "frame payload size overflows allocation"}
+ }
+ return frameHeaderBytes + payloadBytes, nil
+}
+
func readFrame(r io.Reader, limit uint32) ([]byte, error) {
- var header [4]byte
+ var header [frameHeaderBytes]byte
if _, err := io.ReadFull(r, header[:]); err != nil {
return nil, &frameError{message: fmt.Sprintf("read frame length: %v", err)}
}
@@ -100,9 +110,13 @@ func marshalFrame(value any, limit uint32) ([]byte, error) {
return nil, &frameError{message: fmt.Sprintf("frame payload exceeds %d bytes", limit)}
}
- framed := make([]byte, 4+len(payload))
- binary.BigEndian.PutUint32(framed[:4], uint32(len(payload)))
- copy(framed[4:], payload)
+ frameSize, err := checkedFrameSize(len(payload))
+ if err != nil {
+ return nil, err
+ }
+ framed := make([]byte, frameSize)
+ binary.BigEndian.PutUint32(framed[:frameHeaderBytes], uint32(len(payload)))
+ copy(framed[frameHeaderBytes:], payload)
return framed, nil
}
diff --git a/internal/agenthelper/protocol_test.go b/internal/agenthelper/protocol_test.go
index cae1ec877c..124a710ddb 100644
--- a/internal/agenthelper/protocol_test.go
+++ b/internal/agenthelper/protocol_test.go
@@ -3,6 +3,7 @@ package agenthelper
import (
"bytes"
"encoding/binary"
+ "math"
"strings"
"testing"
)
@@ -71,3 +72,14 @@ func TestMarshalFrameEnforcesLimit(t *testing.T) {
t.Fatal("oversized marshaled frame accepted")
}
}
+
+func TestCheckedFrameSizeRejectsInvalidAllocationSizes(t *testing.T) {
+ for _, payloadBytes := range []int{-1, math.MaxInt - frameHeaderBytes + 1} {
+ if _, err := checkedFrameSize(payloadBytes); err == nil {
+ t.Fatalf("invalid payload size accepted: %d", payloadBytes)
+ }
+ }
+ if got, err := checkedFrameSize(128); err != nil || got != frameHeaderBytes+128 {
+ t.Fatalf("checkedFrameSize(128) = %d, %v", got, err)
+ }
+}