diff --git a/content/en/docs/concepts/policy/pod-security-policy.md b/content/en/docs/concepts/policy/pod-security-policy.md index f482c5efb2..52aa593e6f 100644 --- a/content/en/docs/concepts/policy/pod-security-policy.md +++ b/content/en/docs/concepts/policy/pod-security-policy.md @@ -374,6 +374,8 @@ several security mechanisms. {{< codenew file="policy/restricted-psp.yaml" >}} +See [Pod Security Standards](/docs/concepts/security/pod-security-standards/#policy-instantiation) for more examples. + ## Policy Reference ### Privileged @@ -633,6 +635,8 @@ Refer to the [Sysctl documentation]( {{% capture whatsnext %}} +See [Pod Security Standards](/docs/concepts/security/pod-security-standards/) for policy recommendations. + Refer to [Pod Security Policy Reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy) for the api details. {{% /capture %}} diff --git a/content/en/docs/concepts/security/pod-security-standards.md b/content/en/docs/concepts/security/pod-security-standards.md new file mode 100644 index 0000000000..1adf042c91 --- /dev/null +++ b/content/en/docs/concepts/security/pod-security-standards.md @@ -0,0 +1,300 @@ +--- +reviewers: +- tallclair +title: Pod Security Standards +content_template: templates/concept +weight: 10 +--- + +{{% capture overview %}} + +Security settings for Pods are typically applied by using [security +contexts](/docs/tasks/configure-pod-container/security-context/). Security Contexts allow for the +definition of privilege and access controls on a per-Pod basis. + +The enforcement and policy-based definition of cluster requirements of security contexts has +previously been achieved using [Pod Security Policy](/docs/concepts/policy/pod-security-policy/). A +_Pod Security Policy_ is a cluster-level resource that controls security sensitive aspects of the +Pod specification. + +However, numerous means of policy enforcement have arisen that augment or replace the use of +PodSecurityPolicy. The intent of this page is to detail recommended Pod security profiles, decoupled +from any specific instantiation. + +{{% /capture %}} + +{{% capture body %}} + +## Policy Types + +There is an immediate need for base policy definitions to broadly cover the security spectrum. These +should range from highly restricted to highly flexible: + +- **_Privileged_** - Unrestricted policy, providing the widest possible level of permissions. This + policy allows for known privilege escalations. +- **_Baseline/Default_** - Minimally restrictive policy while preventing known privilege + escalations. Allows the default (minimally specified) Pod configuration. +- **_Restricted_** - Heavily restricted policy, following current Pod hardening best practices. + +## Policies + +### Privileged + +The Privileged policy is purposely-open, and entirely unrestricted. This type of policy is typically +aimed at system- and infrastructure-level workloads managed by privileged, trusted users. + +The privileged policy is defined by an absence of restrictions. For blacklist-oriented enforcement +mechanisms (such as gatekeeper), the privileged profile may be an absence of applied constraints +rather than an instantiated policy. In contrast, for a whitelist oriented mechanism (such as Pod +Security Policy) the privileged policy should enable all controls (disable all restrictions). + +### Baseline/Default + +The Baseline/Default policy is aimed at ease of adoption for common containerized workloads while +preventing known privilege escalations. This policy is targeted at application operators and +developers of non-critical applications. The following listed controls should be +enforced/disallowed: + +
| Control | +Policy | +
| Host Namespaces | +
+ Sharing the host namespaces must be disallowed. + Restricted Fields: + spec.hostNetwork + spec.hostPID + spec.hostIPC + Allowed Values: false + |
+
| Privileged Containers | +
+ Privileged Pods disable most security mechanisms and must be disallowed. + Restricted Fields: + spec.containers[*].securityContext.privileged + spec.initContainers[*].securityContext.privileged + Allowed Values: false, undefined/nil + |
+
| Capabilities | +
+ Adding additional capabilities beyond the default set must be disallowed. + Restricted Fields: + spec.containers[*].securityContext.capabilities.add + spec.initContainers[*].securityContext.capabilities.add + Allowed Values: empty (optionally whitelisted defaults) + |
+
| HostPath Volumes | +
+ HostPath volumes must be forbidden. + Restricted Fields: + spec.volumes[*].hostPath + Allowed Values: undefined/nil + |
+
| Host Ports | +
+ HostPorts should be disallowed, or at minimum restricted to a whitelist. + Restricted Fields: + spec.containers[*].ports[*].hostPort + spec.initContainers[*].ports[*].hostPort + Allowed Values: 0, undefined, (whitelisted) + |
+
| AppArmor (optional) | +
+ On supported hosts, the `runtime/default` AppArmor profile is applied by default. The default policy should prevent overriding or disabling the policy, or restrict overrides to a whitelisted set of profiles. + Restricted Fields: + metadata.annotations['container.apparmor.security.beta.kubernetes.io/*'] + Allowed Values: runtime/default, undefined + |
+
| SELinux (optional) | +
+ Setting custom SELinux options should be disallowed. + Restricted Fields: + spec.securityContext.seLinuxOptions + spec.containers[*].securityContext.seLinuxOptions + spec.initContainers[*].securityContext.seLinuxOptions + Allowed Values: undefined/nil + |
+
| Control | +Policy | +
| Everything from the default profile. | +|
| Volume Types | +
+ In addition to restricting HostPath volumes, the restricted profile limits usage of non-core volume types to those defined through PersistentVolumes. + Restricted Fields: + spec.volumes[*].hostPath + spec.volumes[*].gcePersistentDisk + spec.volumes[*].awsElasticBlockStore + spec.volumes[*].gitRepo + spec.volumes[*].nfs + spec.volumes[*].iscsi + spec.volumes[*].glusterfs + spec.volumes[*].rbd + spec.volumes[*].flexVolume + spec.volumes[*].cinder + spec.volumes[*].cephFS + spec.volumes[*].flocker + spec.volumes[*].fc + spec.volumes[*].azureFile + spec.volumes[*].vsphereVolume + spec.volumes[*].quobyte + spec.volumes[*].azureDisk + spec.volumes[*].portworxVolume + spec.volumes[*].scaleIO + spec.volumes[*].storageos + spec.volumes[*].csi + Allowed Values: undefined/nil + |
+
| Privilege Escalation | +
+ Privilege escalation to root should not be allowed. + Restricted Fields: + spec.containers[*].securityContext.privileged + spec.initContainers[*].securityContext.privileged + Allowed Values: false, undefined/nil + |
+
| Running as Non-root | +
+ Containers must be required to run as non-root users. + Restricted Fields: + spec.securityContext.runAsNonRoot + spec.containers[*].securityContext.runAsNonRoot + spec.initContainers[*].securityContext.runAsNonRoot + Allowed Values: true + |
+
| Non-root groups (optional) | +
+ Containers should be forbidden from running with a root primary or supplementary GID. + Restricted Fields: + spec.securityContext.runAsGroup + spec.securityContext.supplementalGroups[*] + spec.securityContext.fsGroup + spec.containers[*].securityContext.runAsGroup + spec.containers[*].securityContext.supplementalGroups[*] + spec.containers[*].securityContext.fsGroup + spec.initContainers[*].securityContext.runAsGroup + spec.initContainers[*].securityContext.supplementalGroups[*] + spec.initContainers[*].securityContext.fsGroup + Allowed Values: + non-zero + undefined / nil (except for `*.runAsGroup`) + |
+
| Seccomp | +
+ The runtime/default seccomp profile must be required, or allow additional whitelisted values. + Restricted Fields: + metadata.annotations['seccomp.security.alpha.kubernetes.io/pod'] + metadata.annotations['container.seccomp.security.alpha.kubernetes.io/*'] + Allowed Values: + runtime/default + undefined (container annotation) + |
+