Files
nuclei-templates/cloud/kubernetes/security-compliance/k8s-apiserver-token-auth-file.yaml
2025-10-23 05:51:22 +00:00

43 lines
1.7 KiB
YAML

id: k8s-apiserver-token-auth-file
info:
name: Detect kube-apiserver --token-auth-file usage
author: songyaeji
severity: high
description: Detects whether kube-apiserver includes the --token-auth-file startup argument.
impact: |
If the API server is started with --token-auth-file, static token file authentication may be allowed, which can enable long-lived or poorly managed tokens and weaken cluster authentication posture.
remediation: |
Remove the --token-auth-file argument from the kube-apiserver startup flags (e.g., edit
/etc/kubernetes/manifests/kube-apiserver.yaml) or ensure any tokens in that file are rotated
and managed securely. Prefer dynamic, short-lived service account tokens and RBAC.
reference:
- https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/
tags: cloud,devops,kubernetes,security,devsecops,api-server,k8s,k8s-cluster-security
variables:
argument: "--token-auth-file"
self-contained: true
code:
- engine:
- sh
- bash
source: |
kubectl get pods -n kube-system -l component=kube-apiserver -o jsonpath="{.items[*].spec.containers[*].command}"
matchers-condition: and
matchers:
- type: word
words:
- 'kube-apiserver'
- type: word
words:
- "{{argument}}"
extractors:
- type: dsl
dsl:
- '"kube-apiserver is configured with " + argument + ". Review and remove if unnecessary."'
# digest: 490a00463044022020656d418d318da59011a310748475bc24891371a85989d21f2257814fd380c40220602a8f6deab1f6328f5cef3edf3033bc51635c50209be15d7fbbe7e9d1096d05:922c64590222798bb761d5b6d8e72950