| name | cis-oke-v170-4.5.2 |
| description | Apply Security Context to Your Pods and Containers (Manual) |
| category | cis-oke |
| version | 1.7.0 |
| author | cyberstrike-official |
| tags | ["cis","oke","kubernetes","oci","policies","general-policies","security-context"] |
| cis_id | 4.5.2 |
| cis_benchmark | CIS Oracle Cloud Infrastructure Container Engine for Kubernetes (OKE) Benchmark v1.7.0 |
| tech_stack | ["kubernetes","oci","oke"] |
| cwe_ids | [] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
CIS OKE Benchmark v1.7.0 - Control 4.5.2
Profile Applicability
Description
Apply Security Context to Your Pods and Containers
Rationale
A security context defines the operating system security settings (uid, gid, capabilities, SELinux role, etc.) applied to a container. When designing your containers and pods, make sure that you configure the security context for your pods, containers, and volumes. A security context is a property defined in the deployment yaml. It controls the security parameters that will be assigned to the pod/container/volume. There are two levels of security context: pod level security context, and container level security context.
Impact
If you incorrectly apply security contexts, you may have trouble running the pods.
Audit Procedure
Review the pod definitions in your cluster and verify that you have security contexts defined as appropriate.
Remediation
As a best practice we recommend that you scope the binding for privileged pods to service accounts within a particular namespace, e.g. kube-system, and limiting access to that namespace. For all other serviceaccounts/namespaces, we recommend implementing a more restrictive policy such as this:
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: restricted
annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: "docker/default,runtime/default"
apparmor.security.beta.kubernetes.io/allowedProfileNames: "runtime/default"
seccomp.security.alpha.kubernetes.io/defaultProfileName: "runtime/default"
apparmor.security.beta.kubernetes.io/defaultProfileName: "runtime/default"
spec:
privileged: false
allowPrivilegeEscalation: false