Skip to content
Security Overview

Security Overview

kornercode provisions browser-accessible development environments. Each workspace is a Kubernetes pod running code-server (VS Code in the browser) for a single developer. The gateway authenticates users and reverse-proxies their traffic to the workspace pods; the operator reconciles the custom resources into pods, services, volumes and network policy labels.

This page summarizes the threat model and the controls that address it. Each control is described in detail on its own page. For the component layout, see the architecture overview.


Threat model

ThreatPrimary controls
Unauthenticated access. Every request to the dashboard, the IDE or the test application must prove the caller’s identity before anything is served or proxied.OIDC login and session check in the gateway (Authentication)
Session theft and reuse across hosts. A session cookie must not be readable by scripts, forgeable, or sent to hosts that do not need it.Encrypted, authenticated, host-only HttpOnly cookies; short-lived bridge tickets for the dev and test hosts (Authentication)
Credential leakage into workspaces. Code running in a workspace must never receive the gateway’s session or the user’s tokens.The proxies strip Cookie and Authorization before forwarding (Authentication)
Cross-site requests against the IDE and the dashboard. A third-party page, or a page on a user’s dev or test host, must not drive a user’s IDE or change anything through the dashboard API in their browser.WebSocket Origin and Sec-Fetch-Site checks in the dev proxy; an Origin check on every state-changing dashboard request (Cross-site request check); SameSite=Lax cookies
Stolen session cookies. A cookie copied from a user’s machine must not be enough to act as that user.Optional client-certificate gate: every request needs the person’s company client certificate, whose CN the session is bound to (Client-certificate gate)
Open redirects during login. The login flow must not redirect to arbitrary sites.Validation of the post-login target (loginTarget, sanitiseRedirect) (Authentication)
Cross-tenant access through the API. A user must only see and change their own workspace.Owner checks on every tenant API call; admin routes gated by ADMIN_GROUPS (Authentication)
Eavesdropping and impersonation on the pod network. Traffic between the gateway and a workspace must be encrypted, and the gateway must only talk to genuine workspace endpoints.Optional mutual TLS with an internal CA and hostname verification (Mutual TLS)
Lateral movement from a workspace. A compromised workspace must not reach other workspaces, the operator, or cluster services it does not need.Label-activated NetworkPolicies (Network isolation)
Privilege escalation inside a workspace. Code in a workspace must not become root on the node or gain Kubernetes API access.Restrictive pod and container security contexts; no ServiceAccount token by default (Pod security)
Administrators locked out during an identity-provider outage. kornercode is a bastion; losing the IdP must not lock out the people who repair it, and the second way in must not be weaker than the first.Optional break-glass button, with the client-certificate gate: a certificate whose CN is in the chart’s mapping signs an administrator in without the IdP (Break-glass login)
Misconfiguration of custom resources. Invalid or dangerous resource definitions must be rejected before the operator acts on them.Admission webhooks, with the rules in operator/api/v1alpha1/validation also applied by the gateway

Defense layers

Browser ──HTTPS──► Ingress (Traefik) ──HTTPS──► Gateway pod
                                                  │
         client certificate check (gate on) ◄─────┤
                    session check (all hosts) ◄───┤
                    admin check (ADMIN_GROUPS) ◄──┤
                                                  │
                                                  │ mTLS (when enabled)
                                                  ▼
                                ┌────────── workspace pod ──────────┐
                                │ Envoy sidecar ──► code-server     │
                                │ NetworkPolicy (activated by label)│
                                │ pod security context              │
                                │ no API token by default           │
                                └───────────────────────────────────┘

Layer 1: OIDC authentication and sessions

Every request to the dashboard API, the dev host (IDE) and the test host must carry a valid session established through the OIDC authorization code flow. AuthMiddleware (gateway/internal/server/middleware.go) enforces this before any handler or proxy runs.

Session cookies are encrypted and authenticated with keys derived from SESSION_SECRET, and are host-only by default. The dashboard hands a session to the dev and test hosts through a 30-second encrypted bridge ticket instead of sharing one cookie across subdomains. Admin routes additionally require membership in one of the ADMIN_GROUPS. See Authentication and sessions.

With the client-certificate gate on (clientCertificates.enabled), every request on the three hosts also needs the person’s company client certificate. The ingress verifies it and forwards it to a gateway listener that only accepts the ingress’s own client certificate; the gateway verifies it again on every request (chain, dates, revocation, a single CN), requires the CN to equal the identity claim at sign-in and the session’s CN afterwards, and re-checks open connections every 30 seconds. Administrators listed in the chart’s breakGlass.mapping can then also sign in with the certificate alone, without the identity provider; break-glass sessions are capped at 8 hours. State-changing dashboard requests must carry the dashboard’s own Origin, gate on or off. See Client-certificate gate.

Layer 2: Mutual TLS between gateway and workspace

When mtls.enabled is set in the chart, traffic from the gateway to each workspace pod is encrypted and mutually authenticated. The gateway presents its certificate, an Envoy sidecar in the workspace pod presents the workspace certificate, and each side verifies the other against an internal CA managed by cert-manager. The gateway also checks that the workspace certificate is valid for the Service hostname it dialed, so it refuses to forward to an endpoint that cannot prove it is that workspace. See Mutual TLS.

Layer 3: Network isolation

Cluster administrators define NetworkPolicies in the operator namespace. The Team controller copies them into every team namespace, and the operator activates them on a workspace pod through labels derived from the Team’s SecurityProfile. The labels are set when the pod is created and kept in sync by the NetworkPolicy step of the Workspace reconciler.

The sample policies in hack/local-dev/workspace-profiles.yaml admit ingress only from the gateway pod. The internet-only sample also blocks egress to RFC 1918 ranges, which prevents a workspace from reaching other pods and cluster services when the cluster’s pod and Service networks use those ranges. A workspace whose Team has no SecurityProfile, or whose profiles disable network policy, is not restricted. See Network isolation.

Layer 4: Pod security contexts

Unless a WorkspaceProfile or SecurityProfile overrides it, workspace pods run with:

  • runAsNonRoot: true and runAsUser, runAsGroup, fsGroup set to 1000;
  • allowPrivilegeEscalation: false;
  • all Linux capabilities dropped;
  • the RuntimeDefault seccomp profile.

Cluster administrators can replace or disable these defaults per WorkspaceProfile or per SecurityProfile. See Pod security.

Layer 5: Kubernetes RBAC

ServiceAccountLocationPermissions
kornercode-operatorOperator namespaceClusterRole kornercode-manager-role, generated from the RBAC markers in operator/cmd/controllers/kornercode/main.go. Cluster-wide management of Pods, Services, PVCs, ConfigMaps, ServiceAccounts, Events and NetworkPolicies; create and update Namespaces; get Secrets (no list or watch); manage the kornercode custom resources and cert-manager Certificates. A namespaced Role covers leader election.
kornercode-gatewayGateway namespaceClusterRole kornercode-gateway (config/helm/templates/gateway/rbac.yaml). Create, update and delete Workspaces, WorkspaceProfiles, Teams and SecurityProfiles; update workspaces/status; read Namespaces, Pods, pod logs, Services and NetworkPolicies; read and delete PVCs; create Events. The gateway uses this identity for all requests and enforces per-user authorization itself.
workspace-runnerEach team namespaceCreated by the operator and used by default. It has no role bindings in team namespaces, and its token is not mounted into workspace pods.
ServiceAccount named by a SecurityProfileEach team namespaceCreated by the operator; its token is mounted into the workspace pods of every Team that uses the SecurityProfile. Its permissions are whatever the cluster administrator binds to it.

Workspace pods set automountServiceAccountToken: false unless the Team’s SecurityProfile names a ServiceAccount. See Pod security.

Layer 6: Admission validation

The operator registers validating webhooks for Workspaces, Teams, WorkspaceProfiles and SecurityProfiles, and a mutating webhook for Workspaces (operator/internal/webhook/v1alpha1). They are enabled when the apiserver serves the cert-manager cert-manager.io/v1 API, which probeCertManager (operator/cmd/controllers/kornercode/certmanager.go) checks at startup. A NotFound answer means cert-manager is absent and the operator runs without webhooks; any other discovery error is retried and then makes the operator exit, so it never silently starts without them. The operator Helm chart always renders the webhook serving certificate and the webhook configurations (with failurePolicy: Fail), so cert-manager is a prerequisite of a Helm installation; see Installation.

ResourceRules enforced on create and update
WorkspaceOn create, a name of at most 53 characters; spec.owner required, at most 58 characters and matching ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$; spec.owner, spec.teamRef, spec.profileRef and spec.lifecycle.deletionPolicy immutable; spec.profileRef and spec.teamRef must exist; the Workspace must live in its Team’s namespace; spec.testPort within 1024 to 65535 and not 8080; spec.ttl positive and not above the profile’s maxTTL when it sets one; on create, every Secret, ConfigMap and PVC the Team mounts must exist
Teamspec.groupClaim required; spec.namespace a valid RFC 1123 label and not a reserved namespace; spec.namespaceLabels free of reserved prefixes; mount names valid pod volume names (DNS-1123 labels that fit in 63 characters with their secret-, configmap- or pvc- prefix) and unique per list; spec.allowedProfiles non-empty and existing; spec.securityProfileRef, when set, existing
WorkspaceProfilespec.image and a non-zero spec.storageSize required; spec.defaultTestPort not 8080; spec.maxTTL positive and not below spec.defaultTTL, which must then be positive; no podSecurityContext or containerSecurityContext together with disableDefaultSecurityContext: true
SecurityProfileEvery spec.networkPolicy.policyRefs entry a valid label value; no podSecurityContext or containerSecurityContext together with disableDefaultSecurityContext: true

All four validators skip updates that leave spec unchanged and updates of objects being deleted, so metadata-only changes such as finalizer removal always succeed. The mutating webhook defaults spec.lifecycle.deletionPolicy to Delete and stamps the code.kornercloud.dev/owner label from spec.owner.

The rules live in operator/api/v1alpha1/validation. The gateway’s admin API applies the namespace, namespace-label and mount-name rules before it creates or updates a Team, and the security-context and policy-reference rules for profiles. Tenant requests are checked for test ports and TTLs, and owner IDs at login.

Layer 7: Audit trail

The gateway records state-changing tenant actions (WorkspaceCreated, WorkspaceTTLExtended, WorkspaceRestarted, WorkspaceDeleted) and every admin “View IDE” (AdminOpenedIDE) as Kubernetes Events on the affected Workspace. Admin API calls are logged and counted in Prometheus. Client-certificate refusals, break-glass logins and refusals, and refusals caused by blockAdminIDEAccess are recorded in the gateway’s audit log. See Audit and observability.


Trust boundaries

┌──────────────────────────────────────────────────────────────────┐
│ Cluster                                                          │
│  ┌──────────────────────────┐       ┌──────────────────────────┐ │
│  │ operator namespace       │       │ team namespace           │ │
│  │ (kornercode)                │ mTLS  │                          │ │
│  │  gateway pod ────────────┼───────┼──► workspace pod         │ │
│  │  operator pod            │       │    (Envoy + code-server) │ │
│  │  managed NetworkPolicies │ copy  │                          │ │
│  │  (source) ───────────────┼───────┼──► NetworkPolicy copies  │ │
│  └──────────────────────────┘       │    ingress: gateway only │ │
│                                     └──────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
  • The gateway is the only intended entry point to workspace pods. With the sample policies, a workspace pod accepts connections only from pods labeled app.kubernetes.io/name: kornercode-gateway in the kornercode namespace. Adjust the selectors if you install the gateway elsewhere.
  • Workspace egress depends on the selected policies. Under internet-only, a workspace cannot open connections to RFC 1918 addresses, which covers the gateway, the operator, the Kubernetes API Service and other pods when the cluster networks use RFC 1918 ranges. Under cluster-access, or without any policy, egress is unrestricted.
  • The gateway and the operator are trusted components. The gateway’s ServiceAccount can create and change every kornercode resource in the cluster, including the SecurityProfiles that decide which ServiceAccount token a workspace receives. The operator can manage pods and read Secrets in every namespace. Protect both namespaces accordingly.
  • Admins are trusted. Members of ADMIN_GROUPS manage profiles, Teams and SecurityProfiles, and can open any user’s IDE. Each IDE opening is recorded as an AdminOpenedIDE Event on the Workspace, which the owner can see.
  • With the client-certificate gate on, the ingress is trusted. It verifies the browser’s certificate and forwards it; the gateway re-verifies it but cannot tell a compromised ingress from a genuine one. The ingress proves itself with a client certificate from kornercode’s internal CA, so anyone allowed to create cert-manager Certificates with the kornercode-internal-ca-issuer ClusterIssuer could impersonate it. Restrict who can use that issuer.
  • Workspace users are not trusted by each other. Code running in a workspace is treated as untrusted input to the rest of the system.
  • The team namespace can be the operator namespace. The local development samples place all Teams in kornercode. In that case the operator does not copy NetworkPolicies (the sources already apply there), and workspace pods share a namespace with the gateway and the operator. Use dedicated team namespaces in production.

What restrictions don’t do

Team and platform restrictions (see the admin guide) make kornercode stop offering things. They are not a wall against everyone.

  • Cluster admins can still get in. Anyone with kubectl exec on the team namespace can enter a pod; kornercode treats admins as trusted. blockAdminIDEAccess removes the one-click path, nothing more.
  • Admins set the team restrictions, so an admin can turn blockAdminIDEAccess off for a team. Only a platform-forced restriction is out of their reach. Where Teams come from GitOps, the change shows up in git review.
  • disableFileDownloads and disableFileUploads only cover code-server’s file transfer. They don’t stop copy-paste, printing a file in the terminal, git push, or network access. NetworkPolicy and the security profile remain the controls for data leaving the workspace.

Known limitations

  • Group membership changes in the IdP, including admin demotions, take effect when the user’s gateway session ends: after 8 hours without activity, or at the latest 24 hours after login (both configurable). See Group propagation lag.
  • Logging out of the dashboard does not clear the separate sessions on the dev and test hosts; they end with the login, at the latest 24 hours after sign-in. See Logout.
  • The client-certificate gate does not protect against malware on the user’s own machine: it can drive the user’s browser, or use a private key the operating system lets the user’s processes use, and so act with the cookie and the certificate together. See What it does not protect against.
  • With the gate on and clientCertificates.revocation.onUnavailable: deny (the default), an outage of the company’s CRL servers that outlasts the cached lists locks everyone out, administrators and break-glass included.
  • Changes to breakGlass.mapping take effect when the gateway restarts with the new mapping; helm upgrade restarts it through a checksum annotation, a ConfigMap edited by hand needs a manual restart. From then on, a removed or edited entry ends that administrator’s break-glass sessions at their next request, on every host.
  • Bridge tickets are not recorded when redeemed, so a ticket can be replayed within its 30-second lifetime. Tickets are encrypted and bound to one host.
  • The NetworkPolicyDisabled condition reflects only the disable flags. A Workspace without any active policy label can still report Enforced. See Network isolation.

Architecture decisions are recorded in the architecture decision records.