pod-seccomp-profile
An Unconfined seccomp profile at pod level removes the syscall filter from every container inheriting it, exposing the full kernel syscall surface including the obscure calls that container escape and privilege-escalation exploits depend on.
(has(object.spec.os) &&
has(object.spec.os.name) &&
object.spec.os.name.lowerAscii() == "windows") ||
!has(object.spec.securityContext) || !has(object.spec.securityContext.seccompProfile) || !has(object.spec.securityContext.seccompProfile.type) || variables.allowedSeccompTypes.exists(t, t == object.spec.securityContext.seccompProfile.type)
spec.securityContext.seccompProfile.type must be undefined, RuntimeDefault, or Localhost.
allowedSeccompTypes
["RuntimeDefault","Localhost"]
Replace Unconfined with RuntimeDefault, or with Localhost naming a profile loaded on the node. Field: spec.securityContext.seccompProfile.type.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: pod-seccomp-profile
annotations:
kubeapt.io/uuid: "7b5bdc67-99f8-4ba3-aeb4-757ae83a95c2"
security.kubeapt.io/displayName: "Runs With an Unconfined Seccomp Profile"
security.kubeapt.io/description: "An Unconfined seccomp profile at pod level removes the syscall filter from every container inheriting it, exposing the full kernel syscall surface including the obscure calls that container escape and privilege-escalation exploits depend on."
security.kubeapt.io/resource: "Pods"
security.kubeapt.io/severity: "Moderate"
security.kubeapt.io/remediation: "Replace Unconfined with RuntimeDefault, or with Localhost naming a profile loaded on the node. Field: spec.securityContext.seccompProfile.type."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
variables:
- name: allowedSeccompTypes
expression: |
["RuntimeDefault","Localhost"]
validations:
- expression: |
(has(object.spec.os) &&
has(object.spec.os.name) &&
object.spec.os.name.lowerAscii() == "windows") ||
!has(object.spec.securityContext) || !has(object.spec.securityContext.seccompProfile) || !has(object.spec.securityContext.seccompProfile.type) || variables.allowedSeccompTypes.exists(t, t == object.spec.securityContext.seccompProfile.type)
message: |
spec.securityContext.seccompProfile.type must be undefined, RuntimeDefault, or Localhost.Save it as pod-seccomp-profile.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./pod-seccomp-profile.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name pod-seccomp-profile -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name pod-seccomp-profile -A