TMAegisBeta
Mais regras para aks

Azure Kubernetes Service (AKS)

TMA-AKS-4.2.4

Minimize the admission of containers wishing to share the host network namespace

AltaNível 1Automatizadaaks

Descrição

Minimize the admission of pods that request spec.hostNetwork=true so that only tightly controlled, explicitly approved platform workloads can share the host network namespace in AKS. As it relates to RBAC and service accounts, this means users, groups, and service accounts with pod or controller deployment rights should not broadly be able to create or update workloads that use host networking, because AKS relies on Kubernetes RBAC to scope who ... Requires kubectl with cluster-wide read access (KUBECONFIG); system namespaces are excluded and listed resources must be remediated or documented as exceptions.

Como é verificado

Método de auditoria: Comando shell

shell
out=$(kubectl get pods -A -o go-template='{{range .items}}{{.metadata.namespace}} {{.metadata.name}} {{.spec.hostNetwork}}{{"\n"}}{{end}}') || exit 1
bad=$(printf '%s\n' "$out" | awk -v ex='^(kube-system|kube-public|kube-node-lease|gatekeeper-system|azure-arc)$' 'NF && $1 !~ ex && ($3=="true")')
if [ -z "$bad" ]; then echo compliant; else printf '%s\n' "$bad" | head -n 25; fi
Saída esperada
compliant

Como é corrigido

Método de correção: Orientação ou patch de infraestrutura

Add policies to each namespace in the cluster which has user workloads to restrict the admission of hostNetwork containers. Pod Security Policies and Assignments can be found by searching for Policies in the Azure Portal. A detailed step-by-step guide can be found here: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/policy-for-kubernetes

Propriedades

Sistemas operacionais
Qualquer
Tags
akspoliciespod-securitynetwork
Referência
CIS Azure Kubernetes Service (AKS) Benchmark v2.0.0 - 4.2.4 Minimize the admission of containers wishing to share the host network namespace

Verificar este host

Execute isto em uma máquina que você tenha permissão para auditar. A varredura é somente leitura.

shell
tmaegis scan --target aks