diff --git a/content/zh/docs/concepts/security/pod-security-standards.md b/content/zh/docs/concepts/security/pod-security-standards.md
index 47a3c5e0da..7a78e66b4c 100644
--- a/content/zh/docs/concepts/security/pod-security-standards.md
+++ b/content/zh/docs/concepts/security/pod-security-standards.md
@@ -14,67 +14,39 @@ weight: 10
-Pod 的安全性配置一般通过使用
-[安全性上下文(Security Context)](/zh/docs/tasks/configure-pod-container/security-context/)
-来保证。安全性上下文允许用户逐个 Pod 地定义特权级及访问控制。
+Pod 安全性标准定义了三种不同的 _策略(Policy)_,以广泛覆盖安全应用场景。
+这些策略是 _渐进式的(Cumulative)_,安全级别从高度宽松至高度受限。
+本指南概述了每个策略的要求。
-以前,对集群的安全性上下文的需求的实施及其基于策略的定义都通过使用
-[Pod 安全性策略](/zh/docs/concepts/policy/pod-security-policy/)来实现。
-_Pod 安全性策略(Pod Security Policy)_ 是一种集群层面的资源,控制 Pod 规约中
-安全性敏感的部分。
-
-不过,新的策略实施方式不断涌现,或增强或替换 PodSecurityPolicy 的使用。
-本页的目的是详细介绍建议实施的 Pod 安全框架;这些内容与具体的实现无关。
+| Profile | 描述 |
+| ------ | ----------- |
+| Privileged | 不受限制的策略,提供最大可能范围的权限许可。此策略允许已知的特权提升。 |
+| Baseline | 限制性最弱的策略,禁止已知的策略提升。允许使用默认的(规定最少)Pod 配置。 |
+| Restricted | 限制性非常强的策略,遵循当前的保护 Pod 的最佳实践。 |
-## 策略类型 {#policy-types}
-
-在进一步讨论整个策略谱系之前,有必要对基本的策略下个定义。
-策略可以是很严格的也可以是很宽松的:
-
-- **_Privileged_** - 不受限制的策略,提供最大可能范围的权限许可。这些策略
- 允许已知的特权提升。
-- **_Baseline_** - 限制性最弱的策略,禁止已知的策略提升。
- 允许使用默认的(规定最少)Pod 配置。
-- **_Restricted_** - 限制性非常强的策略,遵循当前的保护 Pod 的最佳实践。
-
-
-## 策略 {#policies}
+## Profile 细节 {#profile-details}
### Privileged
-Privileged 策略是有目的地开放且完全无限制的策略。此类策略通常针对由
-特权较高、受信任的用户所管理的系统级或基础设施级负载。
+**_Privileged_ 策略是有目的地开放且完全无限制的策略。**
+此类策略通常针对由特权较高、受信任的用户所管理的系统级或基础设施级负载。
Privileged 策略定义中限制较少。对于默认允许(Allow-by-default)实施机制(例如 gatekeeper),
Privileged 框架可能意味着不应用任何约束而不是实施某策略实例。
@@ -93,15 +65,26 @@ Privileged 策略应该默认允许所有控制(即,禁止所有限制)。
### Baseline
-Baseline 策略的目标是便于常见的容器化应用采用,同时禁止已知的特权提升。
+**_Baseline_ 策略的目标是便于常见的容器化应用采用,同时禁止已知的特权提升。**
此策略针对的是应用运维人员和非关键性应用的开发人员。
下面列举的控制应该被实施(禁止):
+{{< note >}}
+在下述表格中,通配符(`*`)意味着一个列表中的所有元素。
+例如 `spec.containers[*].securityContext` 表示 _所定义的所有容器_ 的安全性上下文对象。
+如果所列出的任一容器不能满足要求,整个 Pod 将无法通过校验。
+{{< /note >}}
+
Baseline 策略规范
@@ -110,202 +93,429 @@ Baseline 策略的目标是便于常见的容器化应用采用,同时禁止
| 控制(Control) |
策略(Policy) |
-
-
- | 宿主名字空间 |
-
+
+
+ | HostProcess |
+
- 必须禁止共享宿主名字空间。
- 限制的字段:
- spec.hostNetwork
- spec.hostPID
- spec.hostIPC
- 允许的值: false
+ Windows Pod 提供了运行
+ HostProcess 容器 的能力,
+ 这使得对 Windows 节点的特权访问成为可能。
+ 基线策略中对宿主的特权访问是被禁止的。
+ HostProcess Pod 是 Kubernetes v1.22 版本的
+ alpha 特性。
+ 限制的字段
+
+ spec.securityContext.windowsOptions.hostProcess
+ spec.containers[*].securityContext.windowsOptions.hostProcess
+ spec.initContainers[*].securityContext.windowsOptions.hostProcess
+ spec.ephemeralContainers[*].securityContext.windowsOptions.hostProcess
+
+ 允许的值
+
|
-
- | 特权容器 |
-
+
+ 宿主名字空间 |
+
- 特权 Pod 禁用大多数安全性机制,必须被禁止。
- 限制的字段:
- spec.containers[*].securityContext.privileged
- spec.initContainers[*].securityContext.privileged
- 允许的值: false、未定义/nil
+ 必须禁止共享宿主名字空间。
+ 限制的字段
+
+ spec.hostNetwork
+ spec.hostPID
+ spec.hostIPC
+
+ 允许的值
+
|
-
- | 权能 |
-
+
+ 特权容器 |
+
- 必须禁止添加默认集合之外的权能。
- 限制的字段:
- spec.containers[*].securityContext.capabilities.add
- spec.initContainers[*].securityContext.capabilities.add
- 允许的值: 空(或限定为一个已知列表)
+ 特权 Pod 关闭了大多数安全性机制,必须被禁止。
+ 限制的字段
+
+ spec.containers[*].securityContext.privileged
+ spec.initContainers[*].securityContext.privileged
+ spec.ephemeralContainers[*].securityContext.privileged
+
+ 允许的值
+
|
-
- | HostPath 卷 |
-
+
+ 权能 |
+
- 必须禁止 HostPath 卷。
- 限制的字段:
- spec.volumes[*].hostPath
- 允许的值: 未定义/nil
+ 必须禁止添加除下列字段之外的权能。
+ 限制的字段
+
+ spec.containers[*].securityContext.capabilities.add
+ spec.initContainers[*].securityContext.capabilities.add
+ spec.ephemeralContainers[*].securityContext.capabilities.add
+
+ 允许的值
+
+ - Undefined/nil
+ AUDIT_WRITE
+ CHOWN
+ DAC_OVERRIDE
+ FOWNER
+ FSETID
+ KILL
+ MKNOD
+ NET_BIND_SERVICE
+ SETFCAP
+ SETGID
+ SETPCAP
+ SETUID
+ SYS_CHROOT
+
|
-
- | 宿主端口 |
-
+
+ HostPath 卷 |
+
- 应禁止使用宿主端口,或者至少限定为已知列表。
- 限制的字段:
- spec.containers[*].ports[*].hostPort
- spec.initContainers[*].ports[*].hostPort
- 允许的值: 0、未定义(或限定为已知列表)
+ 必须禁止 HostPath 卷。
+ 限制的字段
+
+ spec.volumes[*].hostPath
+
+ 允许的值
+
|
-
- | AppArmor |
-
+
+ 宿主端口 |
+
- 在被支持的主机上,默认使用 'runtime/default' AppArmor Profile。
- 基线策略应避免覆盖或者禁用默认策略,以及限制覆盖一些 profile 集合的权限。
- 限制的字段:
- metadata.annotations['container.apparmor.security.beta.kubernetes.io/*']
- 允许的值: 'runtime/default'、未定义
+ 应禁止使用宿主端口,或者至少限定为已知列表。
+ 限制的字段
+
+ spec.containers[*].ports[*].hostPort
+ spec.initContainers[*].ports[*].hostPort
+ spec.ephemeralContainers[*].ports[*].hostPort
+
+ 允许的值
+
|
-
- | SELinux |
-
+
+ AppArmor |
+
- 设置 SELinux 类型的操作是被限制的,设置自定义的 SELinux 用户或角色选项是被禁止的。
- 限制的字段:
- spec.securityContext.seLinuxOptions.type
- spec.containers[*].securityContext.seLinuxOptions.type
- spec.initContainers[*].securityContext.seLinuxOptions.type
- 允许的值:
- 未定义/空
- container_t
- container_init_t
- container_kvm_t
- 被限制的字段:
- spec.securityContext.seLinuxOptions.user
- spec.containers[*].securityContext.seLinuxOptions.user
- spec.initContainers[*].securityContext.seLinuxOptions.user
- spec.securityContext.seLinuxOptions.role
- spec.containers[*].securityContext.seLinuxOptions.role
- spec.initContainers[*].securityContext.seLinuxOptions.role
- 允许的值: 未定义或空
+ 在受支持的主机上,默认使用 runtime/default AppArmor Profile。
+ 基线策略应避免覆盖或者禁用默认策略,以及限制覆盖一些 Profile 集合的权限。
+ 限制的字段
+
+ metadata.annotations["container.apparmor.security.beta.kubernetes.io/*"]
+
+ 允许的值
+
+ - 未定义/nil
+ runtime/default
+ localhost/*
+
|
-
- | /proc 挂载类型 |
-
+
+ SELinux |
+
- 要求使用默认的 /proc 掩码以减小攻击面。
- 限制的字段:
- spec.containers[*].securityContext.procMount
- spec.initContainers[*].securityContext.procMount
- 允许的值: 未定义/nil、'Default'
+ 设置 SELinux 类型的操作是被限制的,设置自定义的 SELinux 用户或角色选项是被禁止的。
+ 限制的字段
+
+ spec.securityContext.seLinuxOptions.type
+ spec.containers[*].securityContext.seLinuxOptions.type
+ spec.initContainers[*].securityContext.seLinuxOptions.type
+ spec.ephemeralContainers[*].securityContext.seLinuxOptions.type
+
+ 允许的值
+
+ - 未定义/""
+ container_t
+ container_init_t
+ container_kvm_t
+
+
+ 限制的字段
+
+ spec.securityContext.seLinuxOptions.user
+ spec.containers[*].securityContext.seLinuxOptions.user
+ spec.initContainers[*].securityContext.seLinuxOptions.user
+ spec.ephemeralContainers[*].securityContext.seLinuxOptions.user
+ spec.securityContext.seLinuxOptions.role
+ spec.containers[*].securityContext.seLinuxOptions.role
+ spec.initContainers[*].securityContext.seLinuxOptions.role
+ spec.ephemeralContainers[*].securityContext.seLinuxOptions.role
+
+ 允许的值
+
|
+
+
+ /proc 挂载类型 |
+
+
+ 要求使用默认的 /proc 掩码以减小攻击面。
+ 限制的字段
+
+ spec.containers[*].securityContext.procMount
+ spec.initContainers[*].securityContext.procMount
+ spec.ephemeralContainers[*].securityContext.procMount
+
+ 允许的值
+
+ |
+
+
+ | Seccomp |
+
+
+ Seccomp Profile 禁止被显式设置为 Unconfined。
+ 限制的字段
+
+ spec.securityContext.seccompProfile.type
+ spec.containers[*].securityContext.seccompProfile.type
+ spec.initContainers[*].securityContext.seccompProfile.type
+ spec.ephemeralContainers[*].securityContext.seccompProfile.type
+
+ 允许的值
+
+ - 未定义/nil
+ RuntimeDefault
+ Localhost
+
+ |
+
| Sysctls |
-
+
- Sysctls 可以禁用安全机制或影响宿主上所有容器,因此除了若干『安全』的子集之外,应该被禁止。
- 如果某 sysctl 是受容器或 Pod 的名字空间限制,且与节点上其他 Pod 或进程相隔离,可认为是安全的。
- 限制的字段:
- spec.securityContext.sysctls
- 允许的值:
- kernel.shm_rmid_forced
- net.ipv4.ip_local_port_range
- net.ipv4.tcp_syncookies
- net.ipv4.ping_group_range
- 未定义/空值
+ Sysctls 可以禁用安全机制或影响宿主上所有容器,因此除了若干“安全”的子集之外,应该被禁止。
+ 如果某 sysctl 是受容器或 Pod 的名字空间限制,且与节点上其他 Pod 或进程相隔离,可认为是安全的。
+ 限制的字段
+
+ spec.securityContext.sysctls[*].name
+
+ 允许的值
+
+ - 未定义/nil
+ kernel.shm_rmid_forced
+ net.ipv4.ip_local_port_range
+ net.ipv4.ip_unprivileged_port_start
+ net.ipv4.tcp_syncookies
+ net.ipv4.ping_group_range
+
|
@@ -314,14 +524,26 @@ Baseline 策略的目标是便于常见的容器化应用采用,同时禁止
### Restricted
-Restricted 策略旨在实施当前保护 Pod 的最佳实践,尽管这样作可能会牺牲一些兼容性。
+**_Restricted_ 策略旨在实施当前保护 Pod 的最佳实践,尽管这样作可能会牺牲一些兼容性。**
该类策略主要针对运维人员和安全性很重要的应用的开发人员,以及不太被信任的用户。
下面列举的控制需要被实施(禁止):
+{{< note >}}
+在下述表格中,通配符(`*`)意味着一个列表中的所有元素。
+例如 `spec.containers[*].securityContext` 表示 _所定义的所有容器_ 的安全性上下文对象。
+如果所列出的任一容器不能满足要求,整个 Pod 将无法通过校验。
+{{< /note >}}
+
Restricted 策略规范
@@ -337,90 +559,282 @@ Restricted 策略旨在实施当前保护 Pod 的最佳实践,尽管这样作
| 基线策略的所有要求。 |
-
+
| 卷类型 |
-
- 除了限制 HostPath 卷之外,此类策略还限制可以通过 PersistentVolumes 定义的非核心卷类型。
- 限制的字段:
- 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
- 允许的值: 未定义/nil
+ 除了限制 HostPath 卷之外,此类策略还限制可以通过 PersistentVolumes 定义的非核心卷类型。
+ 限制的字段
+
+ 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[*].photonPersistentDisk
+
+ 允许的值
+
|
-
- | 特权提升 |
+
- 禁止(通过 SetUID 或 SetGID 文件模式)获得特权提升。
-
限制的字段:
- spec.containers[*].securityContext.allowPrivilegeEscalation
- spec.initContainers[*].securityContext.allowPrivilegeEscalation
-
允许的值: false
+ Privilege escalation (such as via set-user-ID or set-group-ID file mode) should not be allowed.
+ Restricted Fields
+
+ spec.containers[*].securityContext.allowPrivilegeEscalation
+ spec.initContainers[*].securityContext.allowPrivilegeEscalation
+ spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
+
+ Allowed Values
+
+ -->
+ 特权提升(v1.8+) |
+
+ 禁止(通过 SetUID 或 SetGID 文件模式)获得特权提升。
+
+ 限制的字段
+
+ spec.containers[*].securityContext.allowPrivilegeEscalation
+ spec.initContainers[*].securityContext.allowPrivilegeEscalation
+ spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
+
+ 允许的值
+
|
-
- | 以非 root 账号运行 |
+
+ 以非 root 账号运行 |
+
-
- 必须要求容器以非 root 用户运行。
- 限制的字段:
- spec.securityContext.runAsNonRoot
- spec.containers[*].securityContext.runAsNonRoot
- spec.initContainers[*].securityContext.runAsNonRoot
- 允许的值: true
+ 必须要求容器以非 root 用户运行。
+ 限制的字段
+
+ spec.securityContext.runAsNonRoot
+ spec.containers[*].securityContext.runAsNonRoot
+ spec.initContainers[*].securityContext.runAsNonRoot
+ spec.ephemeralContainers[*].securityContext.runAsNonRoot
+
+ 允许的值
+
+
+ 如果 Pod 级别 spec.securityContext.runAsNonRoot 设置为
+ true,则允许容器组的安全上下文字段设置为 未定义/nil。
+
|
-
- | 非 root 组 (可选) |
+
+ 非 root 组(可选) |
-
- 禁止容器使用 root 作为主要或辅助 GID 来运行。
- 限制的字段:
- spec.securityContext.runAsGroup
- spec.securityContext.supplementalGroups[*]
- spec.securityContext.fsGroup
- spec.containers[*].securityContext.runAsGroup
- spec.initContainers[*].securityContext.runAsGroup
- 允许的值:
- 非零值
- 未定义/nil (*.runAsGroup 除外)
+
+ 禁止容器使用 root 作为主要或辅助 GID 来运行。
+ 限制的字段
+
+ spec.securityContext.runAsGroup
+ spec.securityContext.supplementalGroups[*]
+ spec.securityContext.fsGroup
+ spec.containers[*].securityContext.runAsGroup
+ spec.initContainers[*].securityContext.runAsGroup
+ spec.ephemeralContainers[*].securityContext.runAsGroup
+
+ 允许的值
+
+ - 未定义/nil(
*.runAsGroup 除外)
+ - 非零值
+
|
- | Seccomp |
+ Seccomp (v1.19+) |
-
- 必须要求使用 RuntimeDefault seccomp profile 或者允许使用特定的 profiles。
- 限制的字段:
- spec.securityContext.seccompProfile.type
- spec.containers[*].securityContext.seccompProfile
- spec.initContainers[*].securityContext.seccompProfile
- 允许的值:
- 'runtime/default'
- 未定义/nil
+
+ Seccomp Profile 必须被显式设置成一个允许的值。禁止使用 Unconfined
+ Profile 或者指定 不存在的 Profile。
+ 限制的字段
+
+ spec.securityContext.seccompProfile.type
+ spec.containers[*].securityContext.seccompProfile.type
+ spec.initContainers[*].securityContext.seccompProfile.type
+ spec.ephemeralContainers[*].securityContext.seccompProfile.type
+
+ 允许的值
+
+ RuntimeDefault
+ Localhost
+
+
+ 如果 Pod 级别的 spec.securityContext.seccompProfile.type
+ 已设置得当,容器级别的安全上下文字段可以为 未定义/nil。
+ 反过来说,如果 _所有的_ 容器级别的安全上下文字段已设置,则 Pod 级别的字段可为 未定义/nil。
+
+ |
+
+
+
+ | 权能(v1.22+) |
+
+
+
+ 容器组必须弃用 ALL 权能,并且只允许添加 NET_BIND_SERVICE 权能。
+
+ 限制的字段
+
+ spec.containers[*].securityContext.capabilities.drop
+ spec.initContainers[*].securityContext.capabilities.drop
+ spec.ephemeralContainers[*].securityContext.capabilities.drop
+
+ 允许的值
+
+
+ 限制的字段
+
+ spec.containers[*].securityContext.capabilities.add
+ spec.initContainers[*].securityContext.capabilities.add
+ spec.ephemeralContainers[*].securityContext.capabilities.add
+
+ 允许的值
+
+ - 未定义/nil
+ NET_BIND_SERVICE
+
|
@@ -443,11 +857,17 @@ of individual policies are not defined here.
随着相关机制的成熟,这些机制会按策略分别定义在下面。特定策略的实施方法不在这里定义。
+[**Pod 安全性准入控制器**](/zh/docs/concepts/security/pod-security-admission/)
+
+- {{< example file="security/podsecurity-privileged.yaml" >}}Privileged namespace{{< /example >}}
+- {{< example file="security/podsecurity-baseline.yaml" >}}Baseline namespace{{< /example >}}
+- {{< example file="security/podsecurity-restricted.yaml" >}}Restricted namespace{{< /example >}}
+
[**PodSecurityPolicy**](/zh/docs/concepts/policy/pod-security-policy/)
-- [Privileged](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/privileged-psp.yaml)
-- [Baseline](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/baseline-psp.yaml)
-- [Restricted](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/restricted-psp.yaml)
+- {{< example file="policy/privileged-psp.yaml" >}}Privileged{{< /example >}}
+- {{< example file="policy/baseline-psp.yaml" >}}Baseline{{< /example >}}
+- {{< example file="policy/restricted-psp.yaml" >}}Restricted{{< /example >}}
安全策略则是控制面用来对安全上下文以及安全性上下文之外的参数实施某种设置的机制。
-在 2020 年 2 月,目前实施这些安全性策略的原生解决方案是
-[Pod 安全性策略](/zh/docs/concepts/policy/pod-security-policy/) - 一种对集群中
-Pod 的安全性策略进行集中控制的机制。
+在 2020 年 7 月,
+[Pod 安全性策略](/zh/docs/concepts/policy/pod-security-policy/)已被废弃,
+取而代之的是内置的 [Pod 安全性准入控制器](/zh/docs/concepts/security/pod-security-admission/)。
+
Kubernetes 生态系统中还在开发一些其他的替代方案,例如
-[OPA Gatekeeper](https://github.com/open-policy-agent/gatekeeper)。
+- [OPA Gatekeeper](https://github.com/open-policy-agent/gatekeeper)。
+- [Kubewarden](https://github.com/kubewarden)。
+- [Kyverno](https://kyverno.io/policies/pod-security/)。
+
+如果你为一个 Windows Pod 应用了 Restricted 策略,**可能会** 对该 Pod 的运行时产生影响。
+Restricted 策略需要强制执行 Linux 特有的限制(如 seccomp Profile,并且禁止特权提升)。
+如果 kubelet 和/或其容器运行时忽略了 Linux 特有的值,那么应该不影响 Windows Pod 正常工作。
+然而,对于使用 Windows 容器的 Pod 来说,缺乏强制执行意味着相比于 Restricted 策略,没有任何额外的限制。
+
+你应该只在 Privileged 策略下使用 HostProcess 标志来创建 HostProcess Pod。
+在 Baseline 和 Restricted 策略下,创建 Windows HostProcess Pod 是被禁止的,
+因此任何 HostProcess Pod 都应该被认为是有特权的。
+