Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is a Pod Security Context?

A security context is the block of a Kubernetes manifest that decides which user a container runs as, which Linux capabilities it keeps, and whether it can gain privileges at runtime.

Illustration for the cybersecurity term Pod Security Context
Home / Blog / Cybersecurity Terms / What Is a Pod Security Context?
17 November 2026

What Is a Pod Security Context?

What Is a Pod Security Context?

A security context is the part of a Kubernetes manifest that tells the container runtime how much privilege a workload gets: which user and group it runs as, which Linux capabilities it keeps, whether its root filesystem is writable, and whether a process inside it can acquire more rights than it started with. It appears as securityContext at two levels — once under spec for the whole pod, and once under each container — and the container-level block wins wherever both set the same field.

The Settings That Matter

A handful of fields account for almost all of the security value.

Platform-specific fields sit alongside these: seLinuxOptions on clusters that enforce SELinux, and the appArmorProfile field that became generally available in Kubernetes 1.31, replacing the older annotation syntax.

A Reasonable Default

apiVersion: v1
kind: Pod
metadata:
  name: invoice-api
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 10001
    fsGroup: 10001
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: api
      image: registry.internal/invoice-api@sha256:9f2c...
      securityContext:
        allowPrivilegeEscalation: false
        readOnlyRootFilesystem: true
        capabilities:
          drop: ["ALL"]
      volumeMounts:
        - name: scratch
          mountPath: /tmp
  volumes:
    - name: scratch
      emptyDir: {}

That manifest satisfies the restricted profile of the Pod Security Standards, and the relationship between the two concepts is worth being precise about: the security context is what you write, and the standards are what the cluster checks it against.

What It Does Not Do

A security context constrains a process within the isolation the kernel already provides. It does not create a new boundary. A kernel vulnerability, a dangerous host path mount, or a shared namespace can still produce an escape — MITRE ATT&CK tracks that outcome as Escape to Host (T1611), and runc flaws such as CVE-2019-5736 and the Leaky Vessels issues disclosed in January 2024, including CVE-2024-21626, are reminders that the runtime itself is in scope. Where a workload is genuinely untrusted, a sandboxed runtime such as gVisor or Kata Containers gives you the boundary that a security context cannot.

Equally, it says nothing about what the pod may talk to, what cloud permissions it inherits, or what secrets it can mount. Those belong to NetworkPolicy, workload identity, and role-based access control respectively, and a hardened security context alongside a service account holding administrator rights over your cloud account is not a secure pod.

Rolling It Out Without Breaking Things

Retrofitting these settings onto an existing estate usually surfaces three problems: images built to run as root, applications that write to their own installation directory, and agents that need a capability nobody documented. Work through it in order. Label namespaces with the restricted standard in warn and audit mode first to produce a list of offenders without blocking anything. Fix images by adding a non-root user in the Dockerfile and setting file ownership at build time rather than patching at runtime. For the few workloads that genuinely require elevated settings, isolate them in their own namespace with a documented exception and tighter monitoring.

If you would like evidence of what a compromised pod could actually reach in your cluster, that is the starting point we use in our cloud security services.

FAQ – Frequently Asked Questions

What Is the Difference Between a Security Context and Pod Security Standards?

The security context is the configuration you write in a pod or container specification. The Pod Security Standards are three named profiles — privileged, baseline, and restricted — that describe acceptable combinations of those settings. Pod Security Admission enforces a profile at namespace level and rejects pods whose security context does not comply. One is the setting; the other is the policy that checks it.

Why Does My Container Fail With runAsNonRoot Enabled?

Usually because the image has no numeric user configured. If the Dockerfile sets no USER, or sets it by name rather than UID, the kubelet cannot confirm the user is non-root and refuses to start the pod. Fix it by creating a user in the image and setting USER to its numeric ID, or set runAsUser explicitly in the manifest and ensure the application can write to the paths it needs.

Do I Need to Drop Capabilities if the Container Runs as Non-Root?

Yes. Running as a non-root user and holding Linux capabilities are separate things, and the default container runtime grants a set of capabilities regardless of the user. Capabilities such as CAP_NET_RAW enable useful attacker behaviour like ARP spoofing from inside the pod. Dropping ALL and adding back only what is needed costs nothing and closes that gap.

Is readOnlyRootFilesystem Practical for Real Applications?

More often than teams expect. Most applications write only to temporary directories, logs, and caches, all of which can be mounted as emptyDir volumes at the specific paths required. The exceptions are legacy software that writes into its own installation directory and some language runtimes that compile on first use. Start with it enabled and add mounts as failures appear, rather than the reverse.

Related Terms

You May Be Interested In These

What Is a Reverse Proxy?

Cybersecurity Terms

17 November 2026

What Is a Reverse Proxy?

Read More
What Was Removed in TLS 1.3?

Cybersecurity Terms

17 November 2026

What Was Removed in TLS 1.3?

Read More
What Is Cyber Insurance?

Cybersecurity Terms

17 November 2026

What Is Cyber Insurance?

Read More