VYPR
Medium severity6.5NVD Advisory· Published Mar 17, 2025· Updated Apr 15, 2026

CVE-2025-29781

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.

PackageAffected versionsPatched versions
github.com/metal3-io/baremetal-operator/apisGo
>= 0.9.0, < 0.9.10.9.1
github.com/metal3-io/baremetal-operator/apisGo
< 0.8.10.8.1

Patches

2
19f8443b1fe1

Merge commit from fork

https://github.com/metal3-io/baremetal-operatorTuomo TanskanenMar 17, 2025via ghsa
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

News mentions

0

No linked articles in our index yet.