[
  {
    "id": "container-001",
    "scenario": "A DevSecOps engineer discovers a critical vulnerability in a Kubernetes deployment during a security audit.",
    "instruction": "Analyze the following Kubernetes misconfigurations and provide remediation steps.",
    "input": "Kubernetes Cluster: production-cluster\nNamespace: default\n\nPod Security Context:\napiVersion: v1\nkind: Pod\nmetadata:\n  name: web-app\nspec:\n  hostNetwork: true\n  hostPID: true\n  containers:\n  - name: app\n    image: nginx:latest\n    securityContext:\n      privileged: true\n      runAsUser: 0\n    volumeMounts:\n    - name: host-fs\n      mountPath: /host\n  volumes:\n  - name: host-fs\n    hostPath:\n      path: /\n\nRBAC Configuration:\napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n  name: admin-binding\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: ClusterRole\n  name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n  name: default\n  namespace: default\n\nTrivy Scan Results:\nnginx:latest (debian 11.6)\nTotal: 147 (UNKNOWN: 0, LOW: 52, MEDIUM: 63, HIGH: 28, CRITICAL: 4)\n\nCRITICAL:\nCVE-2023-0286 - OpenSSL X.400 address type confusion\nCVE-2023-0215 - OpenSSL use-after-free\nCVE-2022-4450 - OpenSSL double-free\nCVE-2022-4304 - OpenSSL timing side-channel",
    "output": "## Kubernetes Security Audit Findings\n\n### Critical Findings\n\n#### 1. Privileged Container (CRITICAL)\n```yaml\nsecurityContext:\n  privileged: true\n  runAsUser: 0\n```\n**Impact**: Container has full host access, can escape to host.\n**Fix**: Remove privileged flag, run as non-root.\n\n#### 2. Host Namespace Sharing (CRITICAL)\n```yaml\nhostNetwork: true\nhostPID: true\n```\n**Impact**: Container shares host network and process namespace.\n**Fix**: Remove hostNetwork and hostPID.\n\n#### 3. Host Filesystem Mount (CRITICAL)\n```yaml\nvolumeMounts:\n- name: host-fs\n  mountPath: /host\nvolumes:\n- name: host-fs\n  hostPath:\n    path: /\n```\n**Impact**: Full host filesystem accessible from container.\n**Fix**: Remove hostPath volume mount.\n\n#### 4. Overly Permissive RBAC (CRITICAL)\n```yaml\nroleRef:\n  kind: ClusterRole\n  name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n  name: default\n```\n**Impact**: Default service account has cluster-admin access.\n**Fix**: Create specific service accounts with minimal permissions.\n\n#### 5. Vulnerable Container Image (CRITICAL)\n```\nnginx:latest\nTotal vulnerabilities: 147\nCritical: 4\nHigh: 28\n```\n**Impact**: Known vulnerabilities exploitable.\n**Fix**: Pin image version, scan regularly.\n\n### Exploitation Scenario\n```bash\n# From privileged container\n# Mount host filesystem\nmount /dev/sda1 /mnt\n\n# Access host files\nchroot /mnt\n\n# Steal secrets\ncat /etc/kubernetes/admin.conf\n\n# Lateral movement\n# Access cluster API with stolen credentials\n```\n\n### Remediation\n\n#### Pod Security Policy\n```yaml\napiVersion: policy/v1beta1\nkind: PodSecurityPolicy\nmetadata:\n  name: restricted\nspec:\n  privileged: false\n  hostNetwork: false\n  hostPID: false\n  volumes:\n  - 'configMap'\n  - 'emptyDir'\n  - 'secret'\n  runAsUser:\n    rule: 'MustRunAsNonRoot'\n```\n\n#### RBAC Fix\n```yaml\napiVersion: rbac.authorization.k8s.io/v1\nkind: Role\nmetadata:\n  name: app-reader\nrules:\n- apiGroups: [\"\"]\n  resources: [\"pods\", \"services\"]\n  verbs: [\"get\", \"list\"]\n```\n\n### Tools Used\n- kube-bench\n- Trivy\n- kubeaudit\n- kubesec",
    "metadata": {
      "category": "container-security",
      "platform": "kubernetes",
      "tools": ["kube-bench", "Trivy", "kubeaudit"],
      "severity": "critical",
      "technique": "security-audit"
    }
  }
]
