logo

Database

Json Yaml Sa Token Enabled

Description

Detects Kubernetes configurations that allow automatic mounting of service account tokens in pods. This can create security risks by providing unnecessary API access to containers, violating the principle of least privilege.

Weakness:

267 - Excessive Privileges - Kubernetes

Category: Functionality Abuse

Detection Strategy

    • Examines Kubernetes manifest files (like pod specs or deployments)

    • Flags if 'automountServiceAccountToken' is explicitly set to 'true'

    • Checks pod specifications under 'spec' that contain container definitions

Vulnerable code example

apiVersion: batch/v1
kind: CronJob
metadata:
  name: vulnerable-cronjob
spec:
  schedule: "0 * * * *"
  jobTemplate:
    spec:...

✅ Secure code example

apiVersion: batch/v1
kind: CronJob
metadata:
  name: secure-cronjob
  labels:
    app: web
spec:
  schedule: "0 * * * *"...