檢視次數:
設定檔適用性:級別 1
在 Kubernetes 中審計容器系統調用的一種方法是使用 seccomp 工具。此工具預設為禁用,但可以用來限制容器的系統調用能力,從而降低核心的攻擊面。Seccomp 還可以通過使用審計配置文件來記錄正在進行的調用。
自訂 seccomp 設定檔定義允許、拒絕或記錄的系統呼叫,以及未指定呼叫的預設操作。
記錄所有系統調用可以幫助管理員了解標準操作所需的系統調用,從而在不丟失系統功能的情況下進一步限制 seccomp 配置文件。它還可以幫助管理員建立 Pod 標準操作模式的基線,使他們能夠識別與此模式的任何重大差異,這些差異可能表明惡意活動。

稽核

執行以下命令並驗證 pods 和容器已配置 seccomp:
kubectl get pods --all-namespaces
確保 pod 和容器在其規範中配置了 seccomp:
  • spec.securityContext.seccompProfile.typeRuntimeDefault
確認註釋值:
  • seccomp.security.alpha.kubernetes.io/pod 是 pods 的 runtime/default
  • container.seccomp.security.alpha.kubernetes.io/<container name> 是容器的 runtime/default

補救

要在 Pod 中啟用自訂 seccomp 配置檔,Kubernetes 管理員可以將其 seccomp 配置檔 JSON 檔案寫入 /var/lib/kubelet/seccomp/ 目錄,並在 Pod 的 securityContext 中新增 seccompProfile
自訂seccompProfile還應包括兩個欄位:Type: LocalhostlocalhostProfile: myseccomppolicy.json
在 pod 和容器配置中,將 spec.securityContext.seccompProfile.typespec.containers[*].securityContext.seccompProfilespec.initContainers[*].securityContext.seccompProfile 設定為 RuntimeDefault
以下是一個 Pod 及其容器的範例規格,將 seccompProfile 設定為 RuntimeDefault
...
spec:
  securityContext:
    seccompProfile:
      type: RuntimeDefault 
  template:
    spec:
      containers:
      - ...
        securityContext:
          seccompProfile: RuntimeDefault