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 OIDC Test HTTP failures private and actionable

pulse-triage[bot]920fb2c0104d
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 8977535063..a9b93d411f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1750,6 +1750,12 @@ token-free command. No copy receipt establishes installed removal or a release.
## Shared Boundaries
+The shared OIDC Test diagnostic exposes only a numeric upstream HTTP status
+and fixed recovery guidance on failed discovery, never a provider/proxy reason
+phrase, header or body. It makes no agent credential, enrollment, lifecycle or
+update-state change and must preserve local administrator recovery. The
+`api-contracts` authenticated consumer verifies this read-only boundary.
+
The shared `internal/api/` audit exporter/summary now refuses synchronous
selections above 10,000 events before verification or encoding. This read-only
boundary does not change agent identity, update/rollback admission, lifecycle
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index a73a49eaf7..482bf35778 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4964,7 +4964,10 @@ the authoritative analysis outcome.
failures without reflecting untrusted discovery values. Successful Test
only establishes discovery and issuer equality, not client credentials or
sign-in, and must say so. Testing must not change saved provider settings,
- secrets, admission restrictions or local administrator recovery.
+ secrets, admission restrictions or local administrator recovery. A non-200
+ discovery response exposes only its numeric HTTP status with fixed recovery
+ guidance; never reflect provider/proxy reason phrases, headers or bodies.
+ The failure must state that nothing was saved and sign-in was not tested.
32. Keep SSO provider-detail payloads edit-complete and non-secret:
`GET /api/security/sso/providers/{id}` may keep flat list/card fields for
summary compatibility, but it must also return the nested OIDC/SAML fields
@@ -7258,6 +7261,11 @@ case, realm, authority and missing-issuer controls to `NewOIDCService`.
collections, non-reflecting failures and unchanged provider/credential/admin
state. The existing Settings SSO result consumes these qualified outcomes;
metadata success alone is never sign-in acceptance.
+`TestOIDCConnectionHTTPStatusPrivacy` sends real custom HTTP/1.1 status lines,
+including long, private-URL and markup reason phrases. Non-200 diagnostics keep
+only `HTTP <numeric status>` and fixed recovery guidance. The authenticated
+consumer contract also checks these failures, no credential/settings/file/admin
+mutation and one read-only discovery request; no upstream body/header is echoed.
That same SSO boundary also owns manual SAML endpoint validation payloads.
`internal/api/identity_sso_handlers.go`, `internal/api/saml_service.go`, and
`internal/api/contract_test.go` must preserve both `idpSsoUrl` and optional
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index c3e459c0f0..05f740642a 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1307,6 +1307,13 @@ Compact Coverage age cells use the existing metadata-size text and reclaim numer
## Shared Boundaries
+The shared OIDC Test diagnostic's failed-discovery response carries only a
+numeric HTTP status and fixed guidance, not provider/proxy reason phrases,
+headers or bodies. Testing does not save settings or replace credentials and
+must not imply successful sign-in or completed recovery. Storage, backup and
+restore state remain untouched; `api-contracts` owns the executable consumer
+and provider/settings/file preservation checks.
+
The shared `internal/api/` audit exporter/summary now refuses synchronous
selections above 10,000 events before verification or encoding, never returning
truncated history as a complete recovery record. Storage recovery, retention,
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index a0d501ddf0..c07ab51f39 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -28283,14 +28283,22 @@ func TestContractSSOOIDCIssuerConsumer(t *testing.T) {
beforeFiles := ssoAdmissionFiles(t, r.config.DataPath)
beforeAuthUser, beforeAuthPass := r.config.AuthUser, r.config.AuthPass
var frames []map[string]interface{}
+ var upstreamStatus atomic.Int32
+ upstreamStatus.Store(http.StatusOK)
+ var requests atomic.Int32
var discovered atomic.Value
discovered.Store("")
server := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ requests.Add(1)
if req.Method != http.MethodGet || req.URL.Path != "/realms/pulse/.well-known/openid-configuration" {
t.Errorf("unexpected diagnostic request: %s %s", req.Method, req.URL.Path)
http.NotFound(w, req)
return
}
+ if status := int(upstreamStatus.Load()); status != http.StatusOK {
+ writeOIDCDiscoveryStatus(t, w, status, "https://idp.example.test/private?secret=SYNTHETIC_REASON_PRIVATE")
+ return
+ }
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]interface{}{
"issuer": discovered.Load().(string), "token_endpoint": "https://idp.example.test/token",
@@ -28300,14 +28308,20 @@ func TestContractSSOOIDCIssuerConsumer(t *testing.T) {
defer server.Close()
issuer := server.URL + "/realms/pulse"
for _, tt := range []struct {
- name, reported, code string
- status int
+ name, reported, code string
+ status, upstreamStatus int
}{
- {"mismatch", issuer + "/other", "issuer_mismatch", http.StatusBadRequest},
- {"missing", "", "missing_discovery_issuer", http.StatusBadRequest},
- {"exact", issuer, "", http.StatusOK},
+ {"mismatch", issuer + "/other", "issuer_mismatch", http.StatusBadRequest, http.StatusOK},
+ {"missing", "", "missing_discovery_issuer", http.StatusBadRequest, http.StatusOK},
+ {"not found", "", "HTTP 404", http.StatusBadRequest, http.StatusNotFound},
+ {"unauthorised", "", "HTTP 401", http.StatusBadRequest, http.StatusUnauthorized},
+ {"limited", "", "HTTP 429", http.StatusBadRequest, http.StatusTooManyRequests},
+ {"unavailable", "", "HTTP 503", http.StatusBadRequest, http.StatusServiceUnavailable},
+ {"exact", issuer, "", http.StatusOK, http.StatusOK},
} {
discovered.Store(tt.reported)
+ upstreamStatus.Store(int32(tt.upstreamStatus))
+ beforeRequests := requests.Load()
payload, _ := json.Marshal(SSOTestRequest{Type: "oidc", OIDC: &OIDCTestConfig{IssuerURL: issuer, ClientID: "synthetic-client"}})
req := httptest.NewRequest(http.MethodPost, "/api/security/sso/providers/test", bytes.NewReader(payload))
req.Header.Set("X-API-Token", token)
@@ -28335,6 +28349,14 @@ func TestContractSSOOIDCIssuerConsumer(t *testing.T) {
} else if response.Details != nil || tt.reported != "" && strings.Contains(w.Body.String(), tt.reported) {
t.Fatal("failure must not echo untrusted issuer or validated details")
}
+ if requests.Load() != beforeRequests+1 {
+ t.Fatal("diagnostic must make exactly one discovery GET and no token/JWKS request")
+ }
+ if tt.upstreamStatus != http.StatusOK {
+ if !strings.Contains(response.Message, "Nothing was saved; sign-in was not tested.") || len(w.Body.Bytes()) > 220 || strings.Contains(w.Body.String(), "SYNTHETIC_") {
+ t.Fatal("upstream HTTP failure must keep bounded recovery guidance without provider text")
+ }
+ }
if strings.Contains(w.Body.String(), "fixture-secret") || strings.Contains(w.Body.String(), "synthetic-token") {
t.Fatal("diagnostic exposed a saved credential")
}
diff --git a/internal/api/identity_sso_handlers.go b/internal/api/identity_sso_handlers.go
index 5e323dcf15..34023e1b19 100644
--- a/internal/api/identity_sso_handlers.go
+++ b/internal/api/identity_sso_handlers.go
@@ -1086,10 +1086,12 @@ func (r *Router) testOIDCConnection(ctx context.Context, cfg *OIDCTestConfig) SS
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
+ // The reason phrase is supplied by the provider or an intervening proxy.
+ // Do not reflect it (or response headers/body) into Settings diagnostics.
return SSOTestResponse{
Success: false,
- Message: "OIDC discovery returned non-200 status",
- Error: resp.Status,
+ Message: "OIDC discovery returned an unexpected HTTP status. Check the Issuer URL and the provider or proxy's access settings. Nothing was saved; sign-in was not tested.",
+ Error: fmt.Sprintf("HTTP %d", resp.StatusCode),
}
}
diff --git a/internal/api/sso_oidc_issuer_test.go b/internal/api/sso_oidc_issuer_test.go
index 2a04f719d4..386ef1f49d 100644
--- a/internal/api/sso_oidc_issuer_test.go
+++ b/internal/api/sso_oidc_issuer_test.go
@@ -2,6 +2,7 @@ package api
import (
"encoding/json"
+ "fmt"
"net/http"
"strings"
"sync/atomic"
@@ -11,6 +12,62 @@ import (
"github.com/stretchr/testify/require"
)
+// Write a real HTTP/1.1 status line: WriteHeader would substitute Go's standard
+// reason phrase and miss the provider-controlled field this regression covers.
+func writeOIDCDiscoveryStatus(t *testing.T, w http.ResponseWriter, status int, reason string) {
+ t.Helper()
+ conn, buf, err := w.(http.Hijacker).Hijack()
+ require.NoError(t, err)
+ defer conn.Close()
+ const body = "SYNTHETIC_BODY_PRIVATE_MARKER"
+ _, err = fmt.Fprintf(buf, "HTTP/1.1 %d %s\r\nContent-Length: %d\r\nX-Provider-Debug: SYNTHETIC_HEADER_PRIVATE\r\nConnection: close\r\n\r\n%s", status, reason, len(body), body)
+ require.NoError(t, err)
+ require.NoError(t, buf.Flush())
+}
+
+func TestOIDCConnectionHTTPStatusPrivacy(t *testing.T) {
+ for _, tt := range []struct {
+ name string
+ status int
+ reason string
+ }{
+ {"redirect without location", 302, "SYNTHETIC_REASON_PRIVATE"},
+ {"unauthorised", 401, "SYNTHETIC_REASON_PRIVATE"},
+ {"forbidden", 403, "SYNTHETIC_REASON_PRIVATE"},
+ {"not found", 404, "Not Found"},
+ {"limited", 429, "SYNTHETIC_REASON_PRIVATE"},
+ {"server error", 500, "SYNTHETIC_REASON_PRIVATE"},
+ {"custom unavailable", 503, "https://idp.example.test/private?secret=SYNTHETIC_REASON_PRIVATE"},
+ {"long unavailable", 503, strings.Repeat("SYNTHETIC_REASON_PRIVATE_", 350)},
+ {"markup", 503, "<script>SYNTHETIC_REASON_PRIVATE</script>"},
+ {"empty", 503, ""},
+ {"nonstandard code", 599, "SYNTHETIC_REASON_PRIVATE"},
+ } {
+ t.Run(tt.name, func(t *testing.T) {
+ var requests atomic.Int32
+ server := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ requests.Add(1)
+ require.Equal(t, http.MethodGet, req.Method)
+ require.Equal(t, "/realm/.well-known/openid-configuration", req.URL.Path)
+ writeOIDCDiscoveryStatus(t, w, tt.status, tt.reason)
+ }))
+ defer server.Close()
+ result := (&Router{}).testOIDCConnection(t.Context(), &OIDCTestConfig{IssuerURL: server.URL + "/realm"})
+ require.False(t, result.Success)
+ require.Nil(t, result.Details)
+ require.Equal(t, fmt.Sprintf("HTTP %d", tt.status), result.Error)
+ require.Equal(t, "OIDC discovery returned an unexpected HTTP status. Check the Issuer URL and the provider or proxy's access settings. Nothing was saved; sign-in was not tested.", result.Message)
+ encoded, err := json.Marshal(result)
+ require.NoError(t, err)
+ require.Less(t, len(encoded), 220, "upstream text must not affect the diagnostic size")
+ for _, private := range []string{"SYNTHETIC_", server.URL, "idp.example.test", "<script>"} {
+ require.NotContains(t, string(encoded), private)
+ }
+ require.Equal(t, int32(1), requests.Load(), "failed discovery must not retry or call token/JWKS endpoints")
+ })
+ }
+}
+
// TestOIDCConnectionIssuerParity compares the diagnostic with the actual
// sign-in service, not a second implementation of the issuer comparison.
func TestOIDCConnectionIssuerParity(t *testing.T) {