CIS K3s Benchmark

Security configuration benchmark for K3s lightweight Kubernetes

v1.0.0 03-2025

Overview

▶

This benchmark provides prescriptive guidance for establishing a secure configuration posture for K3s lightweight Kubernetes. It covers API server authentication, RBAC least privilege, secrets encryption at rest, TLS certificate management, audit logging, network policies, Pod Security Standards, kubeconfig permissions, etcd snapshot backups, and component hardening.

14Recommendations
7Sections
2Profile Levels
SectionAreaFocus
1Installation & ConfigurationVersion management, hardening flags
2Authentication & AuthorizationAnonymous auth, RBAC
3Encryption & TLSSecrets encryption, certificates
4Logging & MonitoringAudit logs, log forwarding
5Network & Pod SecurityNetwork policies, PSS
6File System SecurityKubeconfig, data permissions
7Maintenance & Hardeningetcd snapshots, components

Profile Definitions

▶
ProfileDescriptionIntended Use
L1Level 1 — StandardEssential security for all K3s deployments; minimal performance impact.
L2Level 2 — HardenedAdvanced hardening for PCI-DSS, HIPAA, or high-security environments.

1 — Installation & Configuration

▶

1.1 Version & Server Flags

▶
1.1.1 Ensure K3s is running the latest stable version (Manual)
L1 Manual
Description

This recommendation verifies that K3s is running the latest stable version on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Verify K3s version
k3s --version
kubectl get nodes -o wide
Remediation
# Update K3s to latest stable
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=stable sh -
systemctl restart k3s
1.1.2 Ensure K3s is configured with security hardening flags (Automated)
L1 Auto
Description

This recommendation verifies that K3s is configured with security hardening flags on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check K3s service configuration
systemctl status k3s
ps -eo user,pid,args | grep k3s | grep -v grep
Remediation
# Configure K3s with security flags
curl -sfL https://get.k3s.io | sh -s - server \
  --protect-kernel-defaults \
  --secrets-encryption \
  --kube-apiserver-arg=anonymous-auth=false \
  --kube-apiserver-arg=audit-log-path=/var/log/k3s-audit.log

2 — Authentication & Authorization

▶

2.1 API Server & RBAC

▶
2.1.1 Ensure anonymous authentication is disabled (Automated)
L1 Auto
Description

This recommendation verifies that anonymous authentication is disabled on the K3s lightweight Kubernetes distribution. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the K3s lightweight Kubernetes distribution increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
# Check API server authentication
k3s kubectl auth can-i --list --as=system:anonymous
grep 'anonymous-auth' /etc/systemd/system/k3s.service
Remediation
# Disable anonymous authentication
# Add to K3s server flags:
# --kube-apiserver-arg=anonymous-auth=false
# Verify:
kubectl get --raw /api/v1/namespaces --as=system:anonymous 2>&1 | grep -i forbid
2.1.2 Ensure RBAC with least privilege is configured (Automated)
L1 Auto
Description

This recommendation verifies that RBAC with least privilege is configured on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check RBAC configuration
kubectl get clusterrolebindings -o custom-columns=NAME:.metadata.name,ROLE:.roleRef.name,SUBJECTS:.subjects | head -20
kubectl auth can-i --list --as=system:serviceaccount:default:default
Remediation
# Configure RBAC least privilege
kubectl delete clusterrolebinding permissive-binding 2>/dev/null
# Create namespace-scoped roles:
kubectl create role app-reader --verb=get,list,watch --resource=pods,services -n app-ns
kubectl create rolebinding app-reader-binding --role=app-reader --serviceaccount=app-ns:app-sa -n app-ns
# Restrict default service account:
kubectl patch serviceaccount default -n default -p '{"automountServiceAccountToken":false}'

3 — Encryption & TLS

▶

3.1 Secrets & Certificates

▶
3.1.1 Ensure secrets encryption at rest is enabled (Automated)
L1 Auto
Description

This recommendation verifies that secrets encryption at rest is enabled on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check secrets encryption
k3s secrets-encrypt status
ls -la /var/lib/rancher/k3s/server/cred/encryption-config.json 2>/dev/null
Remediation
# Enable secrets encryption at rest
k3s secrets-encrypt enable
k3s secrets-encrypt reencrypt
# Verify:
k3s secrets-encrypt status
# Check encryption config:
cat /var/lib/rancher/k3s/server/cred/encryption-config.json | python3 -m json.tool
3.1.2 Ensure TLS certificates are properly configured and rotated (Automated)
L1 Auto
Description

This recommendation verifies that TLS certificates are properly configured and rotated on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check TLS certificate configuration
ls -la /var/lib/rancher/k3s/server/tls/
openssl x509 -in /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt -noout -dates
Remediation
# Configure custom TLS certificates
# Use --tls-san for additional SANs:
curl -sfL https://get.k3s.io | sh -s - server \
  --tls-san=k3s.example.com \
  --tls-san=10.0.1.100
# Rotate certificates:
k3s certificate rotate
systemctl restart k3s
# Monitor cert expiry:
openssl x509 -in /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt -noout -enddate

4 — Logging & Monitoring

▶

4.1 Audit & System Logs

▶
4.1.1 Ensure API server audit logging is enabled (Automated)
L1 Auto
Description

This recommendation verifies that API server audit logging is enabled on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check audit logging
grep 'audit-log' /etc/systemd/system/k3s.service
ls -la /var/log/k3s-audit.log 2>/dev/null
Remediation
# Enable audit logging
# Create audit policy:
cat > /etc/rancher/k3s/audit-policy.yaml << 'EOF'
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: Metadata
  resources:
  - group: ""
    resources: ["secrets", "configmaps"]
- level: RequestResponse
  users: ["system:admin"]
- level: Metadata
EOF
# Add flags:
# --kube-apiserver-arg=audit-policy-file=/etc/rancher/k3s/audit-policy.yaml
# --kube-apiserver-arg=audit-log-path=/var/log/k3s-audit.log
# --kube-apiserver-arg=audit-log-maxage=30
# --kube-apiserver-arg=audit-log-maxsize=100
4.1.2 Ensure K3s service logs are forwarded and rotated (Automated)
L1 Auto
Description

This recommendation verifies that K3s service logs are forwarded and rotated on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check K3s logging
journalctl -u k3s --no-pager | tail -20
kubectl logs -n kube-system -l app=traefik | head -10
Remediation
# Configure centralized logging
# K3s logs to journald by default
# Forward to syslog:
cat > /etc/rsyslog.d/k3s.conf << 'EOF'
if $programname == 'k3s' then /var/log/k3s.log
& stop
EOF
systemctl restart rsyslog
# Configure log rotation:
cat > /etc/logrotate.d/k3s << 'EOF'
/var/log/k3s*.log {
    daily
    rotate 30
    compress
    missingok
}
EOF

5 — Network & Pod Security

▶

5.1 Policies & Standards

▶
5.1.1 Ensure default-deny network policies are applied (Automated)
L1 Auto
Description

This recommendation verifies that default-deny network policies are applied on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check network policies
kubectl get networkpolicies --all-namespaces
kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik
Remediation
# Configure default-deny network policies
kubectl apply -f - << 'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
  namespace: default
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
EOF
# Then allow specific traffic per application
5.1.2 Ensure Pod Security Standards are enforced (Automated)
L1 Auto
Description

This recommendation ensures that Pod Security Standards are enforced on the K3s lightweight Kubernetes distribution. Enforcing this requirement establishes a minimum security standard and prevents insecure configurations.

Rationale

Without this enforcement, the K3s lightweight Kubernetes distribution may accept insecure configurations that weaken overall security posture. Mandating this control ensures consistent protection against common attack vectors.

Audit
# Check Pod Security Standards
kubectl get ns --show-labels | grep pod-security
kubectl describe ns kube-system | grep pod-security
Remediation
# Enforce Pod Security Standards
kubectl label ns default pod-security.kubernetes.io/enforce=restricted
kubectl label ns default pod-security.kubernetes.io/warn=restricted
kubectl label ns default pod-security.kubernetes.io/audit=restricted
# Configure K3s default PSA:
# --kube-apiserver-arg=enable-admission-plugins=PodSecurity

6 — File System Security

▶

6.1 Kubeconfig & Data Permissions

▶
6.1.1 Ensure kubeconfig file permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that kubeconfig file permissions are restricted on the K3s lightweight Kubernetes distribution. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the K3s lightweight Kubernetes distribution is essential for defense in depth.

Audit
# Check kubeconfig permissions
stat -c '%a %U %G' /etc/rancher/k3s/k3s.yaml
find /var/lib/rancher/k3s -name '*.kubeconfig' -exec stat -c '%a %n' {} \;
Remediation
# Restrict kubeconfig permissions
chmod 600 /etc/rancher/k3s/k3s.yaml
chown root:root /etc/rancher/k3s/k3s.yaml
chmod 700 /var/lib/rancher/k3s/server/cred
chmod 600 /var/lib/rancher/k3s/server/cred/*
6.1.2 Ensure data directory permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that data directory permissions are restricted on the K3s lightweight Kubernetes distribution. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the K3s lightweight Kubernetes distribution is essential for defense in depth.

Audit
# Check data directory permissions
stat -c '%a %U %G' /var/lib/rancher/k3s
find /var/lib/rancher/k3s/server -maxdepth 1 -type d -exec stat -c '%a %n' {} \;
Remediation
# Restrict data directory permissions
chmod 750 /var/lib/rancher/k3s
chmod 700 /var/lib/rancher/k3s/server
chmod 700 /var/lib/rancher/k3s/server/tls
chmod 600 /var/lib/rancher/k3s/server/tls/*.key

7 — Maintenance & Hardening

▶

7.1 Snapshots & Components

▶
7.1.1 Ensure automated etcd snapshots are configured (Automated)
L1 Auto
Description

This recommendation verifies that automated etcd snapshots are configured on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check etcd snapshot configuration
k3s etcd-snapshot list 2>/dev/null
grep 'etcd-snapshot' /etc/systemd/system/k3s.service
Remediation
# Configure automated etcd snapshots
# Add to K3s server flags:
# --etcd-snapshot-schedule-cron='0 */6 * * *'
# --etcd-snapshot-retention=10
# --etcd-snapshot-dir=/var/lib/rancher/k3s/server/db/snapshots
# Manual snapshot:
k3s etcd-snapshot save --name=manual-$(date +%F)
7.1.2 Ensure unnecessary bundled components are disabled (Automated)
L1 Auto
Description

This recommendation verifies that unnecessary bundled components are disabled on the K3s lightweight Kubernetes distribution. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the K3s lightweight Kubernetes distribution vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check disabled components
grep -E 'disable|no-deploy' /etc/systemd/system/k3s.service
Remediation
# Disable unnecessary components
# If Traefik not needed:
curl -sfL https://get.k3s.io | sh -s - server \
  --disable=traefik \
  --disable=servicelb
# If using external metrics:
# --disable=metrics-server
# Verify:
kubectl get pods -n kube-system