git:20260521.94c412d to git:20260521.27b4bc9

15 added, 17 removed. Audit A to A.

---
name: review-security-k8s-storage
description: Reviews Kubernetes Storage configurations, PersistentVolumes, and VolumeMounts for security vulnerabilities and data leakage risks.
---
-
- # Instructions
- You are a Kubernetes security expert. Your task is to review Kubernetes storage configurations (`StorageClass`, `PersistentVolume`, `PersistentVolumeClaim`), Volume definitions, and `VolumeMounts` within workloads to ensure data security and prevent privilege escalation.
-
- ## Focus Areas & Deterministic Checks:
+ # Task
+ Review storage configurations (`StorageClass`, `PersistentVolume`, `PVC`), Volumes, and `VolumeMounts` to prevent data leaks and privilege escalation.
- ### 1. Volume Mount & Workload Storage Security
- - **Read-Only Mounts**: Flag `VolumeMounts` that do not explicitly set `readOnly: true` for inherently writable volume types such as `PersistentVolumeClaims` (PVCs), `hostPath`, and `emptyDir`. Write access should only be granted when strictly necessary for application functionality. (Note: `secrets`, `configmaps`, `downwardAPI`, and `projected` volumes are inherently read-only at the kubelet level, so missing `readOnly: true` on those is not a security risk).
- - **subPath Abuse**: Scrutinize the use of `subPath` in volume mounts. Historically, `subPath` has been vulnerable to symlink breakout attacks. Flag if `subPath` is used with volumes that are writable by untrusted users.
- - **hostPath Volumes**: Flag any use of `hostPath` volumes. While also checked at the pod/node level, storage reviews should actively recommend migrating these to safer alternatives like `local` PersistentVolumes if host-level storage is genuinely required.
- - **fsGroup Configuration**: Evaluate the pod `securityContext` for proper `fsGroup` usage. Setting an `fsGroup` ensures the volume's permissions are properly scoped to a specific non-root group, eliminating the need for the container to run as root just to read or write to its persistent storage.
+ # Checks
+ ## 1. Volume Mount Security
+ - **Read-Only**: Flag `VolumeMounts` missing `readOnly: true` for writable types (`PVCs`, `hostPath`, `emptyDir`) unless write is required.
+ - **subPath Abuse**: Flag `subPath` on volumes writable by untrusted users (symlink breakout risk).
+ - **hostPath**: Flag `hostPath` usage. Recommend `local` PVs.
+ - **fsGroup**: Require `fsGroup` in `securityContext` to avoid running containers as root for storage access.
- ### 2. StorageClass & PersistentVolume Security
- - **Access Modes (RWX vs RWO)**: Flag PersistentVolumes or PersistentVolumeClaims requesting `ReadWriteMany` (RWX). RWX allows multiple nodes to mount the volume as writable simultaneously, which significantly expands the blast radius if even a single attached pod is compromised. Recommend restricting to `ReadWriteOnce` (RWO) or `ReadOnlyMany` (ROX) unless distributed write access is strictly required by the architecture.
- - **Encryption at Rest**: Review `StorageClass` configurations to ensure they enforce encryption at rest at the infrastructure layer (e.g., passing parameters to the cloud provider like `encrypted: "true"` for AWS EBS, or specifying CMEK keys for GCP).
- - **Insecure Reclaim Policies**: Flag the deprecated `Recycle` reclaim policy. Beyond performing an insecure `rm -rf` scrub, this policy is officially deprecated and its presence is a strong signal that the YAML is severely outdated. If you see `Recycle`, heavily scrutinize the rest of the manifest for other legacy mistakes or deprecated configurations. For the `Retain` policy, flag if the volume contains sensitive data and lacks a documented, automated process for wiping the disk before it is manually released or re-bound.
- - **Volume Expansion Risks**: Check if `allowVolumeExpansion: true` is set on `StorageClasses`. If enabled without strict `ResourceQuotas` at the namespace level, an attacker could continually expand PVCs to exhaust underlying cluster storage resources (a form of DoS).
+ ## 2. StorageClass & PV Security
+ - **Access Modes**: Flag `ReadWriteMany` (RWX). Require `ReadWriteOnce` (RWO) or `ReadOnlyMany` (ROX) to reduce blast radius.
+ - **Encryption**: Require `StorageClasses` to enforce encryption at rest (e.g., CMEK, `encrypted: "true"`).
+ - **Reclaim Policies**: Flag deprecated `Recycle`. Flag `Retain` on sensitive volumes without automated wipe processes.
+ - **Volume Expansion**: Flag `allowVolumeExpansion: true` without strict namespace `ResourceQuotas` (DoS risk).
- ### 3. CSI Drivers & Secrets Management
- - **CSI Secret Store Configurations**: If the Container Storage Interface (CSI) Secrets Store driver is used (e.g., via `SecretProviderClass`), review its configuration. Ensure it explicitly limits which specific secrets can be mounted and doesn't rely on overly permissive cloud identities to access the underlying cloud secret manager.
+ ## 3. CSI Drivers
+ - **CSI Secrets**: For CSI Secrets Store, require strict limits on mountable secrets and cloud identity access.