Skip to content

[v0.15] fix(agent): apply pod-security labels from namespaceLabels again - #5706

Merged
p-se merged 1 commit into
rancher:release/v0.15from
p-se:bp-5550-v0.15
Sep 3, 2026
Merged

[v0.15] fix(agent): apply pod-security labels from namespaceLabels again#5706
p-se merged 1 commit into
rancher:release/v0.15from
p-se:bp-5550-v0.15

Conversation

@p-se

@p-se p-se commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

namespaceLabels in fleet.yaml exists so that a bundle can label the namespace it deploys into, and setting Pod Security Admission labels that way is what SURE-5906 (#1484) asked for. Since #5156 the agent dropped every pod-security.kubernetes.io/ key from the options and skipped those keys when pruning, so labels a user declares are silently ignored (SURE-11931, #5550).

That filter was the fix for GHSA-864g-863m-vcvq, where a bundle could weaken PSA enforcement on its target namespace because the agent applied namespaceLabels with its own cluster-admin credentials. #5351 changed that: the namespace is patched as the deployment's service account, so downstream RBAC decides what a bundle may write to it, and the prefix filter is no longer the control it was.

The filter never covered the whole path either. The same label reaches the same API call, under the same credentials, when it is declared on a Namespace object in the bundle, or when a pre-provisioned namespace is adopted with helm.takeOwnership. It also matched on the key alone, so it refused tightening enforcement, and setting warn or audit levels, just as it refused weakening.

Pod-security labels are therefore treated like every other namespace label again: applied when declared, pruned when they are not. Dropping the pruning exemption as well keeps un-setting working, which that exemption broke for these keys specifically.

Deployments that resolve to no service account still patch the namespace as the agent, which is cluster admin. Restricting those requires pinning a service account, in the bundle or through a Policy.

Refers to #5702

(cherry picked from commit 51c99ee)

Additional Information

Checklist

  • I have updated the documentation via a pull request in the fleet-product-docs repository.

namespaceLabels in fleet.yaml exists so that a bundle can label the
namespace it deploys into, and setting Pod Security Admission labels
that way is what SURE-5906 (rancher#1484) asked for. Since rancher#5156 the agent
dropped every pod-security.kubernetes.io/ key from the options and
skipped those keys when pruning, so labels a user declares are silently
ignored (SURE-11931, rancher#5550).

That filter was the fix for GHSA-864g-863m-vcvq, where a bundle could
weaken PSA enforcement on its target namespace because the agent applied
namespaceLabels with its own cluster-admin credentials. rancher#5351 changed
that: the namespace is patched as the deployment's service account, so
downstream RBAC decides what a bundle may write to it, and the prefix
filter is no longer the control it was.

The filter never covered the whole path either. The same label reaches
the same API call, under the same credentials, when it is declared on a
Namespace object in the bundle, or when a pre-provisioned namespace is
adopted with helm.takeOwnership. It also matched on the key alone, so it
refused tightening enforcement, and setting warn or audit levels, just
as it refused weakening.

Pod-security labels are therefore treated like every other namespace
label again: applied when declared, pruned when they are not. Dropping
the pruning exemption as well keeps un-setting working, which that
exemption broke for these keys specifically.

Deployments that resolve to no service account still patch the namespace
as the agent, which is cluster admin. Restricting those requires pinning
a service account, in the bundle or through a Policy.

Refers to rancher#5702

(cherry picked from commit 51c99ee)
@p-se
p-se requested a review from a team as a code owner September 2, 2026 10:14
@p-se p-se changed the title fix(agent): apply pod-security labels from namespaceLabels again [v0.15] fix(agent): apply pod-security labels from namespaceLabels again Sep 2, 2026
@p-se
p-se merged commit a79a732 into rancher:release/v0.15 Sep 3, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants