Secure OpenShift Dev Spaces

Red Hat OpenShift Dev Spaces 3.29

Control access, manage permissions, and enforce compliance

Abstract

Protect your OpenShift Dev Spaces deployment by hardening access controls, managing user permissions, enforcing container security policies, and complying with data protection regulations.

Preface

Protect your OpenShift Dev Spaces deployment by hardening access controls, managing user permissions, and ensuring compliance with organizational security policies and data protection regulations.

Chapter 1. Protect your deployment

Protect your Red Hat OpenShift Dev Spaces deployment by applying these security practices to safeguard developer credentials, isolate workspaces, and reduce the cluster attack surface.

Red Hat OpenShift Dev Spaces runs on top of OpenShift, which provides the platform, and the foundation for the products functioning on top of it. OpenShift documentation is the entry point for security hardening.

1.1. What is secure by default

OpenShift Dev Spaces applies these protections automatically when you install it. No configuration is required:

  • Project isolation. Each developer gets a dedicated <username>-devspaces project. Users cannot access other users' resources.
  • Role-based access control (RBAC). The Operator creates ClusterRoles that grant developers permissions only within their own project.
  • Authentication. Only authenticated OpenShift users can access OpenShift Dev Spaces. The gateway enforces RBAC on every request.
  • Container security context. Workspace pods run as non-root with dropped capabilities. The container-build SecurityContextConstraint adds only SETGID and SETUID for container builds.

1.2. What you must configure

These security tasks require administrator action:

  • OAuth for Git providers. Without OAuth, developers must manually create personal access token secrets. Set up OAuth for your Git providers to give developers credential-free repository access.
  • Access restrictions. By default, all authenticated OpenShift users can access OpenShift Dev Spaces. Use the advancedAuthorization CheCluster property to restrict access to specific users and groups.

For Git OAuth setup and for restricting platform access, see Additional resources.

1.3. What you can optionally harden

These additional measures strengthen your security posture but are not required:

  • Network policies. Control ingress and egress traffic between workspace pods to limit the attack surface.
  • Resource quotas and limit ranges. Prevent resource abuse by setting per-project consumption constraints.
  • Extension management. Restrict IDE extensions to trusted sources, especially in air-gapped environments.
  • Self-signed certificates. Import custom TLS certificates if your Git server or artifact repositories use internal certificate authorities.

1.4. Project isolation for developer workspaces

In OpenShift, project isolation is similar to namespace isolation in Kubernetes but is achieved through the concept of projects. A project in OpenShift is a top-level organizational unit that provides isolation and collaboration between different applications, teams, or workloads within a cluster.

By default, OpenShift Dev Spaces provisions a unique <username>-devspaces project for each user. Alternatively, the cluster administrator can disable project self-provisioning on the OpenShift level, and turn off automatic namespace provisioning in the CheCluster custom resource:

devEnvironments:
  defaultNamespace:
    autoProvision: false

With this setup, you achieve curated access to OpenShift Dev Spaces. Cluster administrators control provisioning for each user and can explicitly configure various settings including resource limits and quotas. For more information about provisioning projects in advance, see Additional resources.

1.5. Default RBAC permissions for workspace users

By default, the OpenShift Dev Spaces operator creates the following ClusterRoles:

  • <namespace>-cheworkspaces-clusterrole
  • <namespace>-cheworkspaces-devworkspace-clusterrole

The <namespace> prefix corresponds to the project name where the Red Hat OpenShift Dev Spaces CheCluster CR is located. The first time a user accesses Red Hat OpenShift Dev Spaces, the corresponding RoleBinding is created in the <username>-devspaces project.

The following table lists the resources and actions that you can grant users permission to use in their namespace.

Table 1.1. Overview of resources and actions available in a user’s namespace

ResourcesActions

pods

"get", "list", "watch", "create", "delete", "update", "patch"

pods/exec

"get", "create"

pods/log

"get", "list", "watch"

pods/portforward

"get", "list", "create"

configmaps

"get", "list", "create", "update", "patch", "delete"

events

"list", "watch"

secrets

"get", "list", "create", "update", "patch", "delete"

services

"get", "list", "create", "delete", "update", "patch"

routes

"get", "list", "create", "delete"

persistentvolumeclaims

"get", "list", "watch", "create", "delete", "update", "patch"

apps/deployments

"get", "list", "watch", "create", "patch", "delete"

apps/replicasets

"get", "list", "patch", "delete"

namespaces

"get", "list"

projects

"get"

devworkspace

"get", "create", "delete", "list", "update", "patch", "watch"

devworkspacetemplates

"get", "create", "delete", "list", "update", "patch", "watch"

Important

Each user is granted permissions only to their namespace and cannot access other users' resources. Cluster administrators can add extra permissions to users. They should not remove permissions granted by default.

For more details about configuring cluster roles for Red Hat OpenShift Dev Spaces users and role-based access control, see the Additional resources section.

1.6. What runs in each developer namespace

Isolation of the development environments is implemented using OpenShift projects. Every developer has a project in which the following objects are created and managed:

  • Cloud Development Environment (CDE) Pods, including the Integrated Development Environment (IDE) server.
  • Secrets containing developer credentials, such as a Git token, SSH keys, and a Kubernetes token.
  • ConfigMaps with developer-specific configuration, such as the Git name and email.
  • Volumes that persist data such as the source code, even when the CDE Pod is stopped.
Important

Access to the resources in a namespace must be limited to the developer owning it. Granting read access to another developer is equivalent to sharing the developer credentials and should be avoided.

1.7. Restrict platform access with allow and deny lists

By default, every authenticated OpenShift user can access OpenShift Dev Spaces. To limit the platform to specific users and groups, configure the advancedAuthorization properties in the CheCluster Custom Resource:

  • allowUsers
  • allowGroups
  • denyUsers
  • denyGroups

Users on a deny list cannot use OpenShift Dev Spaces and see a warning when they try to open the User Dashboard. If a user appears on both allow and deny lists, access is denied. For the procedure to configure allow and deny lists, see Additional resources.

1.8. How gateway authentication controls access

Only authenticated OpenShift users can access Red Hat OpenShift Dev Spaces. The Gateway Pod uses a role-based access control (RBAC) subsystem to determine whether a developer is authorized to access a Cloud Development Environment (CDE) or not.

The CDE Gateway container checks the developer’s Kubernetes roles. If their roles allow access to the CDE Pod, the connection to the development environment is allowed. By default, only the owner of the namespace has access to the CDE Pod.

1.9. Security context for container builds

Red Hat OpenShift Dev Spaces adds SETGID and SETUID capabilities to the specification of the CDE Pod container security context:

"spec": {
  "containers": [
    "securityContext": {
            "allowPrivilegeEscalation": true,
            "capabilities": {
               "add": ["SETGID", "SETUID"],
               "drop": ["ALL","KILL","MKNOD"]
            },
            "readOnlyRootFilesystem": false,
            "runAsNonRoot": true,
            "runAsUser": 1001110000
   }
  ]
 }

This provides the ability for users to build container images from within a CDE.

By default, Red Hat OpenShift Dev Spaces assigns users a specific SecurityContextConstraint (SCC) that allows them to start a Pod with such capabilities. This SCC grants more capabilities to the users compared to the default restricted SCC but less capability compared to the anyuid SCC. This default SCC is pre-created in the OpenShift Dev Spaces namespace and named container-build.

Setting the following property in the CheCluster Custom Resource prevents assigning extra capabilities and SCC to users:

spec:
  devEnvironments:
    disableContainerBuildCapabilities: true

1.10. Resource quotas and limit ranges

Resource Quotas and Limit Ranges are Kubernetes features you can use to help prevent bad actors and resource abuse within a cluster. Specifically, they allow you to set resource consumption constraints for pods and containers. By combining Resource Quotas and Limit Ranges, you can enforce project-specific policies to prevent bad actors from consuming excessive resources.

These mechanisms contribute to better resource management, stability, and fairness within an OpenShift cluster. For more information about resource quotas and limit ranges, see Additional resources.

1.11. Network policies for workspace pods

Network policies provide an additional layer of security by controlling network traffic between pods in a Kubernetes cluster. By default, every pod can communicate with every other pod and service on the cluster.

Implementing network policies allows you to:

  • Control ingress and egress traffic to and from workspace pods
  • Limit the attack surface by denying unauthorized network access

When configuring network policies for Red Hat OpenShift Dev Spaces, ensure that pods in the OpenShift Dev Spaces namespace can still communicate with pods in user namespaces. This communication is required for proper functionality. For detailed instructions on configuring network policies, see Additional resources.

1.12. Security in disconnected and air-gapped deployments

In a disconnected or air-gapped OpenShift cluster, nodes cannot reach public registries or the internet. That isolation reduces exposure to external threats, but you must supply container images, IDE extensions, and dependencies from internal registries that you control.

OpenShift Dev Spaces supports restricted-network installation. For installation steps, see Additional resources. Restrict IDE extensions to trusted internal sources as described in Secure IDE extensions in workspaces.

1.13. Secure IDE extensions in workspaces

By default, Red Hat OpenShift Dev Spaces includes the embedded Open VSX registry which contains a limited set of extensions for the Microsoft Visual Studio Code - Open Source editor. Alternatively, cluster administrators can specify a different plugin registry in the Custom Resource, for example the open-vsx.org registry that contains thousands of extensions. They can also build a custom Open VSX registry.

Important

Installing extra extensions increases potential risks. To minimize these risks, ensure that you only install extensions from reliable sources and regularly update them.

For more information about managing IDE extensions, see Additional resources.

1.14. Protect developer credentials and secrets

Developer credentials such as personal access tokens (PATs), SSH keys, and Kubernetes tokens are stored as Secrets in each user’s project. Treat those Secrets as confidential. Granting another user read access to a developer namespace is equivalent to sharing that developer’s credentials.

Prefer organization-wide Git OAuth so developers do not create and store long-lived personal tokens in every Cloud Development Environment. For Git OAuth setup and for mounting secrets into workspaces, see Additional resources.

1.15. Trusted Git repositories and dependencies

Operate only on Git repositories that your organization trusts. Before adding new dependencies, confirm that maintainers publish security updates for known vulnerabilities. Untrusted repositories and outdated dependencies increase supply-chain risk for every Cloud Development Environment that clones them.

For credential-free Git access that reduces token sprawl, see Additional resources.

Chapter 2. Control who can access OpenShift Dev Spaces

Control who can access OpenShift Dev Spaces by restricting it to authorized users and groups, managing permissions, and complying with data protection regulations such as GDPR.

2.1. Grant additional permissions to users

Grant your developers additional OpenShift permissions by adding cluster roles so they can access resources beyond the default workspace operations.

Prerequisites

Procedure

  1. Define the user roles name:

    $ USER_ROLES=<name>

    where:

    name
    Unique resource name.
  2. Determine the namespace where the OpenShift Dev Spaces Operator is deployed:

    $ OPERATOR_NAMESPACE=$(oc get pods -l app.kubernetes.io/component=devspaces-operator -o jsonpath={".items[0].metadata.namespace"} --all-namespaces)
  3. Create needed roles:

    $ oc apply -f - <<EOF
    kind: ClusterRole
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
      name: ${USER_ROLES}
      labels:
        app.kubernetes.io/part-of: che.eclipse.org
    rules:
      - verbs:
          - <verbs>
        apiGroups:
          - <apiGroups>
        resources:
          - <resources>
    EOF

    where:

    verbs
    List all Verbs that apply to all ResourceKinds and AttributeRestrictions contained in this rule. You can use * to represent all verbs.
    apiGroups
    Name the APIGroups that contain the resources.
    resources
    List all resources that this rule applies to. You can use * to represent all verbs.
  4. Delegate the roles to the OpenShift Dev Spaces Operator:

    $ oc apply -f - <<EOF
    kind: ClusterRoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
      name: ${USER_ROLES}
      labels:
        app.kubernetes.io/part-of: che.eclipse.org
    subjects:
      - kind: ServiceAccount
        name: devspaces-operator
        namespace: ${OPERATOR_NAMESPACE}
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: ${USER_ROLES}
    EOF
  5. Configure the OpenShift Dev Spaces Operator to delegate the roles to the che service account:

    $ oc patch checluster devspaces \
      --patch '{"spec": {"components": {"cheServer": {"clusterRoles": ["'${USER_ROLES}'"]}}}}' \
      --type=merge -n {prod-namespace}
  6. Configure the OpenShift Dev Spaces server to delegate the roles to a user:

    $ oc patch checluster devspaces \
      --patch '{"spec": {"devEnvironments": {"user": {"clusterRoles": ["'${USER_ROLES}'"]}}}}' \
      --type=merge -n {prod-namespace}
  7. Wait for the rollout of the OpenShift Dev Spaces server components to complete.
  8. Ask the user to log out and log in to have the new roles applied.

Verification

  • Verify that the ClusterRole exists:

    $ oc get clusterrole ${USER_ROLES}

2.2. Restrict access to specific users and groups

Restrict OpenShift Dev Spaces access to specific users and groups so that you can control which users are allowed or denied access to the platform.

Prerequisites

Procedure

  1. Edit the CheCluster Custom Resource to add the advancedAuthorization section:

    $ oc patch checluster devspaces --type=merge -n openshift-devspaces \
      --patch '{
        "spec": {
          "networking": {
            "auth": {
              "advancedAuthorization": {
                "allowUsers": ["<allow_users>"],
                "allowGroups": ["<allow_groups>"],
                "denyUsers": ["<deny_users>"],
                "denyGroups": ["<deny_groups>"]
              }
            }
          }
        }
      }'

    where:

    allowUsers
    List of users allowed to access Red Hat OpenShift Dev Spaces.
    allowGroups
    List of groups of users allowed to access Red Hat OpenShift Dev Spaces (for OpenShift Container Platform only).
    denyUsers
    List of users denied access to Red Hat OpenShift Dev Spaces.
    denyGroups

    List of groups of users denied access to Red Hat OpenShift Dev Spaces (for OpenShift Container Platform only).

    If a user is on both allow and deny lists, access is denied. If allowUsers and allowGroups are empty, all users are allowed except the ones on the deny lists. If denyUsers and denyGroups are empty, only the users from allow lists are allowed. If both allow and deny lists are empty, all users are allowed.

  2. Wait for the rollout of the OpenShift Dev Spaces server components to complete.

Verification

  • Log in to the OpenShift Dev Spaces dashboard as a user on the allowUsers list and verify access to the dashboard.
  • Log in as a user on the denyUsers list and verify that OpenShift Dev Spaces displays the following message:

    Advanced authorization is enabled. User might not be allowed. Please, contact the administrator.

2.3. Remove user data for GDPR compliance

Remove a user’s data from OpenShift Container Platform when a developer leaves your organization, to comply with the Content from gdpr.eu is not included.General Data Protection Regulation (GDPR). The process for other Kubernetes infrastructures might vary.

Warning

Removing user data as follows is irreversible. All removed data is deleted and unrecoverable.

Prerequisites

Procedure

  1. List all the users in the OpenShift cluster using the following command:

    $ oc get users
  2. Delete the user entry:

    Important

    If the user has any associated resources (such as projects, roles, or service accounts), you must delete those first before deleting the user.

    $ oc delete user <username>

Verification

  • Verify the user no longer appears in the cluster:

    $ oc get users

Revised on 2026-07-27 19:48:02 UTC

Legal Notice

Copyright © Red Hat.
Except as otherwise noted below, the text of and illustrations in this documentation are licensed by Red Hat under the Creative Commons Attribution–Share Alike 3.0 Unported license . If you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, the Red Hat logo, JBoss, Hibernate, and RHCE are trademarks or registered trademarks of Red Hat, LLC. or its subsidiaries in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS is a trademark or registered trademark of Hewlett Packard Enterprise Development LP or its subsidiaries in the United States and other countries.
The OpenStack® Word Mark and OpenStack logo are trademarks or registered trademarks of the Linux Foundation, used under license.
All other trademarks are the property of their respective owners.