Not Unique Certificate Authority

  • Query id: cb7e695d-6a85-495c-b15f-23aed2519303
  • Query name: Not Unique Certificate Authority
  • Platform: Kubernetes
  • Severity: Medium
  • Category: Secret Management
  • URL: Github

Description

Certificate Authority should be unique for etcd
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - yaml file
apiVersion: apps/v1
kind: Deployment
metadata:
  name: database
spec:
  selector:
    matchLabels:
      app: database
      version: v1
  replicas: 1
  template:
    metadata:
      labels:
        app: database
        version: v1
    spec:
      serviceAccountName: database
      containers:
      - name: database
        image: gcr.io/google_containers/kube-apiserver:certification
        imagePullPolicy: IfNotPresent
        command: ["etcd"]
        args: ["--trusted-ca-file=/etc/env/valid3.pem"]
      nodeSelector:
        kubernetes.io/hostname: worker02  
    restartPolicy: OnFailure
---
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command: ["kube-apiserver"]
      args: ["--client-ca-file=/etc/env/valid3.pem"]
  restartPolicy: OnFailure

Code samples without security vulnerabilities

Negative test num. 1 - yaml file
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command: ["kube-apiserver"]
      args: ["--client-ca-file=/etc/env/valid.pem"]
  restartPolicy: OnFailure
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: database
spec:
  selector:
    matchLabels:
      app: database
      version: v1
  replicas: 1
  template:
    metadata:
      labels:
        app: database
        version: v1
    spec:
      serviceAccountName: database
      containers:
      - name: database
        image: gcr.io/google_containers/kube-apiserver:certification
        imagePullPolicy: IfNotPresent
        command: ["etcd"]
        args: ["--trusted-ca-file=/etc/env/valid2.pem"]
      nodeSelector:
        kubernetes.io/hostname: worker02  
    restartPolicy: OnFailure