T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- SKILL.md:121
- Finding
- Shadow Deployment Inherits Production Credentials and Privileges<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 121-147 **Vulnerability Type**: Production privilege and secret inheritance **Risk Level**: High ### Vulnerable Code ```bash # Clone the production deployment with shadow labels kubectl get deployment "$SERVICE_NAME" -n "$NAMESPACE" -o json | python3 -c " import json, sys deploy = json.load(sys.stdin) # Modify for shadow deploy['metadata']['name'] += '-shadow' deploy['metadata'].pop('resourceVersion', None) deploy['metadata'].pop('uid', None) deploy['metadata'].pop('creationTimestamp', None) deploy['metadata']['labels']['version'] = 'shadow' deploy['metadata']['labels']['traffic-role'] = 'shadow' deploy['spec']['selector']['matchLabels']['version'] = 'shadow' deploy['spec']['template']['metadata']['labels']['version'] = 'shadow' deploy['spec']['template']['metadata']['labels']['traffic-role'] = 'shadow' # Set shadow image for c in deploy['spec']['template']['spec']['containers']: c['image'] = c['image'].rsplit(':', 1)[0] + ':shadow' # Reduce replicas for shadow (it only needs to handle, not serve) deploy['spec']['replicas'] = max(1, deploy['spec'].get('replicas', 1) // 2) print(json.dumps(deploy, indent=2)) " | kubectl apply -f - ``` ### Technical Analysis The procedure copies the complete production Deployment specification and changes only selected metadata, labels, image tags, and replica count. Security-sensitive pod settings are not removed or restricted. The resulting shadow pods can inherit: - The production Kubernetes service account and its RBAC permissions. - Secrets supplied through environment variables or `envFrom`. - Secret, projected-token, and persistent-volume mounts. - Cloud workload identity annotations or credentials. - Production network connectivity. - Privileged security contexts, Linux capabilities, or host resources. - Sidecars that possess credentials or administrative access. The container image is then changed to a `:shadow` tag without validating an i ...[truncated 1435 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Create a dedicated shadow Deployment instead of cloning the complete production pod template. - Assign a dedicated service account with no Kubernetes API permissions unless explicitly required. - Remove production `env`, `envFrom`, secret volumes, projected tokens, persistent volumes, and workload-identity annotations. - Set `automountServiceAccountToken: false` when Kubernetes API access is unnecessary. - Use a dedicated read-only or sanitized data source rather than production databases and queues. - Apply a restrictive NetworkPolicy that permits only the minimum required ingress and egress. - Enforce a hardened security context, including non-root execution, a read-only root filesystem, seccomp, and removal of unnecessary Linux capabilities. - Select the shadow image explicitly and pin it to a reviewed immutable digest rather than deriving a mutable `:shadow` tag. - Validate the generated manifest and require operator approval before applying it. ]]>
