CVE-2025-29781
Description
The Bare Metal Operator (BMO) implements a Kubernetes API for managing bare metal hosts in Metal3. Baremetal Operator enables users to load Secret from arbitrary namespaces upon deployment of the namespace scoped Custom Resource BMCEventSubscription. Prior to versions 0.8.1 and 0.9.1, an adversary Kubernetes account with only namespace level roles (e.g. a tenant controlling a namespace) may create a BMCEventSubscription in his authorized namespace and then load Secrets from his unauthorized namespaces to his authorized namespace via the Baremetal Operator, causing Secret Leakage. The patch makes BMO refuse to read Secrets from other namespace than where the corresponding BMH resource is. The patch does not change the BMCEventSubscription API in BMO, but stricter validation will fail the request at admission time. It will also prevent the controller reading such Secrets, in case the BMCES CR has already been deployed. The issue exists for all versions of BMO, and is patched in BMO releases v0.9.1 and v0.8.1. Prior upgrading to patched BMO version, duplicate any existing Secret pointed to by BMCEventSubscription's httpHeadersRef to the same namespace where the corresponding BMH exists. After upgrade, remove the old Secrets. As a workaround, the operator can configure BMO RBAC to be namespace scoped, instead of cluster scoped, to prevent BMO from accessing Secrets from other namespaces, and/or use WATCH_NAMESPACE configuration option to limit BMO to single namespace.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/metal3-io/baremetal-operator/apisGo | >= 0.9.0, < 0.9.1 | 0.9.1 |
github.com/metal3-io/baremetal-operator/apisGo | < 0.8.1 | 0.8.1 |
Patches
2ea8528e73bf919f8443b1fe1Merge commit from fork
4 files changed · +114 −0
apis/metal3.io/v1alpha1/bmceventsubscription_validation.go+6 −0 modified@@ -29,6 +29,12 @@ func (s *BMCEventSubscription) validateSubscription() []error { errs = append(errs, errors.New("hostName cannot be empty")) } + if s.Spec.HTTPHeadersRef != nil { + if s.Spec.HTTPHeadersRef.Namespace != s.Namespace { + errs = append(errs, errors.New("httpHeadersRef secret must be in the same namespace as the BMCEventSubscription")) + } + } + if s.Spec.Destination == "" { errs = append(errs, errors.New("destination cannot be empty")) } else {
apis/metal3.io/v1alpha1/bmceventsubscription_validation_test.go+23 −0 modified@@ -3,6 +3,7 @@ package v1alpha1 import ( "testing" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -69,6 +70,28 @@ func TestBMCEventSubscriptionValidateCreate(t *testing.T) { oldS: nil, wantedErr: "hostname-only destination must have a trailing slash", }, + { + name: "httpHeadersRef valid", + newS: &BMCEventSubscription{ + TypeMeta: tm, + ObjectMeta: om, + Spec: BMCEventSubscriptionSpec{HostName: "worker-01", Destination: "http://localhost/abc/abc.php", + HTTPHeadersRef: &corev1.SecretReference{Namespace: om.Namespace, Name: "headers"}}, + }, + oldS: nil, + wantedErr: "", + }, + { + name: "httpHeadersRef in different namespace", + newS: &BMCEventSubscription{ + TypeMeta: tm, + ObjectMeta: om, + Spec: BMCEventSubscriptionSpec{HostName: "worker-01", Destination: "http://localhost/abc/abc.php", + HTTPHeadersRef: &corev1.SecretReference{Namespace: "different", Name: "headers"}}, + }, + oldS: nil, + wantedErr: "httpHeadersRef secret must be in the same namespace as the BMCEventSubscription", + }, } for _, tt := range tests {
controllers/metal3.io/bmceventsubscription_controller.go+4 −0 modified@@ -243,6 +243,10 @@ func (r *BMCEventSubscriptionReconciler) getHTTPHeaders(ctx context.Context, sub return headers, nil } + if subscription.Spec.HTTPHeadersRef.Namespace != subscription.Namespace { + return headers, errors.New("httpHeadersRef secret must be in the same namespace as the BMCEventSubscription") + } + secret := &corev1.Secret{} secretKey := types.NamespacedName{ Name: subscription.Spec.HTTPHeadersRef.Name,
controllers/metal3.io/bmceventsubscription_controller_test.go+81 −0 modified@@ -139,3 +139,84 @@ func TestBMCGetProvisioner(t *testing.T) { }) } } + +func TestGetHTTPHeaders(t *testing.T) { + // NOTE: This subscription references the defaultSecretName for http headers. + // The secret is automatically created by newBMCTestReconciler. + host := newDefaultHost(t) + subscription := newDefaultSubscription(t) + r := newBMCTestReconciler(subscription, host) + + for _, tc := range []struct { + Scenario string + Subscription *metal3api.BMCEventSubscription + Secret *corev1.Secret + ExpectedError bool + }{ + { + Scenario: "Secret exists and has some content", + Subscription: subscription, + // Already created by newBMCTestReconciler. + Secret: nil, + ExpectedError: false, + }, + { + Scenario: "Secret does not exist", + Subscription: &metal3api.BMCEventSubscription{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-subscription", + Namespace: namespace, + }, + Spec: metal3api.BMCEventSubscriptionSpec{ + HostName: host.Name, + HTTPHeadersRef: &corev1.SecretReference{ + Name: "non-existent-secret", + Namespace: namespace, + }, + }, + }, + Secret: nil, + ExpectedError: true, + }, + { + Scenario: "Secret in wrong namespace", + Subscription: &metal3api.BMCEventSubscription{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-subscription", + Namespace: namespace, + }, + Spec: metal3api.BMCEventSubscriptionSpec{ + HostName: host.Name, + HTTPHeadersRef: &corev1.SecretReference{ + Name: "test", + Namespace: "separate-namespace", + }, + }, + }, + Secret: nil, + ExpectedError: true, + }, + } { + t.Run(tc.Scenario, func(t *testing.T) { + if tc.Secret != nil { + err := r.Create(context.Background(), tc.Secret) + if err != nil { + t.Fatal(err) + } + } + + headers, err := r.getHTTPHeaders(context.Background(), *tc.Subscription) + if tc.ExpectedError && err == nil { + t.Error("Expected error but got none") + } + if !tc.ExpectedError { + if err != nil { + t.Errorf("Expected no error but got: %v", err) + } + if len(headers) == 0 { + t.Error("Expected headers but got none") + } + } + }) + } +}
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-c98h-7hp9-v9hqghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2025-29781ghsaADVISORY
- github.com/metal3-io/baremetal-operator/commit/19f8443b1fe182f76dd81b43122e8dd102f8b94cnvdWEB
- github.com/metal3-io/baremetal-operator/pull/2321nvdWEB
- github.com/metal3-io/baremetal-operator/pull/2322nvdWEB
- github.com/metal3-io/baremetal-operator/security/advisories/GHSA-c98h-7hp9-v9hqnvdWEB
- github.com/metal3-io/metal3-docs/blob/main/design/baremetal-operator/bmc-events.mdnvdWEB
News mentions
0No linked articles in our index yet.