Skip to content

feat(kubernetes): enforce a namespace boundary for gateway write permissions #6010

Todo

Description

@SDAChess

User Story

As a cluster operator running OpenShell on Kubernetes alongside other applications, I need the gateway's write permissions limited to its workspace namespaces and explicitly configured gateway resources. I want Kubernetes to enforce that boundary when deploying OpenShell with least privilege.

Problem Statement

The Helm chart binds the gateway ClusterRole cluster-wide. In managed workspace mode, it grants Secret create and delete across all namespaces. Managed and operator modes also receive cluster-wide Pod mutations and Service/NetworkPolicy creation.

The managed-mode Secret rule is reported as critical finding KSV-0041 in the Helm security scan. It grants neither Secret get nor list. The underlying namespace scope is the concern; the driver legitimately creates generation-scoped bootstrap Secrets and deletes them during cleanup/recovery.

The driver's namespace ownership checks do not narrow the Kubernetes authority of its ServiceAccount.

Impact / Why This Matters

The gateway's Kubernetes credentials carry write authority over namespaces unrelated to OpenShell. Operators cannot rely on workspace selection alone as a Kubernetes-enforced permission boundary.

This is a least-privilege hardening request based on the published chart permissions, not a demonstrated path from an ordinary sandbox to gateway credentials. Removing required verbs would break sandbox lifecycle operations.

Proposed Design

Provide a documented deployment workflow where namespaced writes are authorized only in explicitly enrolled workspace namespaces and other explicitly configured namespaces/resources needed by the gateway. Retain required cluster-level authentication and discovery operations.

For example, a gateway serving openshell-gw-team-a and openshell-gw-team-b should complete sandbox lifecycle operations there while Kubernetes rejects equivalent writes to an unrelated payments namespace.

Define the managed-workspace provisioning and upgrade behavior under this boundary. Choose the enforcement mechanism during design review rather than assuming the gateway can grant itself namespace permissions safely.

Acceptance Criteria

  • The supported least-privilege deployment documents the gateway's effective permissions and any required exceptions.
  • Sandbox create, bootstrap, stop/start, recovery, and delete work in enrolled workspace namespaces.
  • Kubernetes rejects direct gateway writes to unrelated namespaces, including Secret and workload mutations; checks cover the gateway ServiceAccount independently of OpenShell API validation.
  • Namespace provisioning, deletion, and ownership changes cannot bypass the boundary.
  • The gateway cannot recover equivalent cluster-wide authority through unrestricted Role/RoleBinding creation, bind, or escalate permissions.
  • Helm coverage, a Kubernetes deployment test, and upgrade documentation validate the chosen behavior.

Alternatives Considered

  • Operator mode and the workspace chart: already provide namespace-scoped Secret grants, but the gateway ClusterRole still grants cluster-wide workload writes. feat: let Helm grant only cluster discovery for one operator workspace #5374 proposes a narrower discovery role for one pre-provisioned operator workspace; this request also covers managed provisioning and the broader write boundary.
  • Externally supplied RBAC: available through the options introduced by feat(helm): gate cluster-scoped RBAC so the gateway chart can be installed without cluster-admin #3043, but operators must maintain the permission set and provisioning workflow themselves.
  • Kubernetes admission enforcement: potentially preserves automatic provisioning while enforcing namespace ownership. It needs independent enforcement and ownership protection; the broad RBAC finding may remain visible to static scanners.
  • Gateway-only validation or extension hooks: do not constrain direct Kubernetes requests using gateway credentials.
  • Deleting the flagged Secret rule alone: breaks bootstrap/recovery and leaves cluster-wide workload write authority.

Evidence

Inspected source at 92a45c1debc30ea503ee052cfbba452a3db00e43:

Activity

  1. added
    state:accepted
    topic:security
    area:runtime
    area:drivers
    topic:kubernetes
    and removed
    area:runtime
    on Nov 26, 2026
  2. rudrakshkarpe commented on Nov 27, 2026

    @rudrakshkarpe

    I'd like to help with this, @TaylorMutch. Would a focused contribution around the permission matrix and Kubernetes boundary tests be useful? I'd cover lifecycle operations in enrolled namespaces and direct ServiceAccount requests against an unrelated namespace, including namespace ownership and privilege-escalation cases. I also noticed #5374 and would coordinate with that work before changing the chart. Could you please share which parts you're already implementing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:driversstate:acceptedtopic:kubernetestopic:security

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions