Understanding DevSecOps for Kubernetes

Reading Time: 4 minutes

Increase in Security Demands for Cloud Native Ecosystems

In today’s world, the need for securing our cloud native clusters has increased more than ever. Also this year, cloud-native security is again top trending, according to a report published by Gartner. DevSecOps is a simple answer to multiple questions.

In the recently concluded KubeCon 2020, we saw that a lot of organisations are taking huge strides and wanting more people in the DevSecOps sector. We also have a specific branch for Kubernetes which is appropriately name KubeSecOps.

Another factor in understanding how important security is to the different organisations now is that even after already high demand certifications like CKA and CKAD, the Cloud Native Computing Foundations has introduced a new course, Certified Kubernetes Security Specialist.

CNCF Security Landscape

DevSecOps: Security at Container Level

In regard to container security, there are basically 6 factors that need to be considered:
1. Image Scanning
2. Container Compliance
3. Runtime Security
4. Network Security
5. Forensics
6. Kubernetes Audit

Concerns related to container security:

  1. Container host security
  2. Container network traffic
  3. Application security inside the container
  4. Malicious behaviour within the application
  5. Securing your container management stack
  6. The foundation layers of your application
  7. The integrity of the build pipeline

The reasons for above concerns can be traced to the following possible reasons but not limited to these:

  1. Kubelet API not secured
  2. Unrestricted cloud metadata with sensitive information
  3. Unprotected secrets
  4. Lacking adequate network policies
  5. No ingress authentication for services
  6. No authentication on etcd
  7. Privileged containers
  8. More than required service account privileges

The main thing that DevSecOps concerns itself with is finding vulnerabilities at the time of cluster creation. We can always list out some of the questions to be asked for securing our Kubernetes cluster:

  1. Has authentication been enabled?
  2. Are we familiar with the base image while building our custom images and are those official images?
  3. Is root access required for our application while running the container?
  4. Are the containers in the proper namespaces while deployment?
  5. Is there a need for Transport Layer Security
  6. Has cluster hardening been done?
  7. Are pod security policies implemented?
  8. What ports are exposed for a pod?
  9. Is there audit logging?
  10. Are we using sidecars while injecting secrets?
  11. Are we implementing security policies while storing secrets?

Below are the charts sourced from various forums giving recommendation for different tools that can be used for ensuring security while creating a cluster and deploying our applications.

devsecops-tools1
Scanning Scenarios
devsecops-tools2
Security Tools
devsecops-tools3
Language Recommendations

DevSecOps: Designing a Security Pipeline

We have now made our-self familiar with most of the demands and factors needed for ensuring security on the grounds of KubeSecOps and ultimately DevSecOps. Now, the next question that arises is how do we ingest security in a Kubernetes pipeline while making it accessible for the required components?

devsecops-pipeline
DevSecOps Pipeline
kubesecops-pipeline
KubeSecOps Pipeline

Lets take a look at various type of tools we can use for creating the Pipelines:

Development

IDE: Any well maintained IDE will work fine.
Open Policy Agent: Defines policy in linting the code and integrates with the IDE itself.
Vault: For secret management
Image Registry: If possible, image registry should be private. Recommendations are JFrog and Harbor
Image Scanner: Tool to find vulnerabilities in an image. The most popular is Trivy.
Update Framework: Image signing and secure upgrades i
s done via tools like TUF.

Staging

The above tools are most useful for the development process. Now lets have a look at the factors and see we can use during the staging process:

Bench-marking: It is required for getting recommendations and warnings to correct possible vulnerabilities. Kube-bench is a highly rated tool for the same.
Penetration: We can use Kube-Hunter as a penetration tool. For instance, it will look for network, interface security breach/weakness remotely.
Audit: Scan manifests and cluster to perform audit because of various vulnerabilities might get exposed there.
Network Policies: There should be regular scan for network policies. Illuminatio is a tool which will do so along with building test cases and execute them to determine if the policies are in effect.

Once we have considered all these factors and setup our cluster accordingly, our application is ready to go to production. As a result, we will be needing runtime security analysis based on kernel scanning of vulnerabilities and notify for any live attacks. Falco is a tool that can be used for the same and it is also capable of sending security metrics to Prometheus. Thus, we can the integrate Prometheus and Grafana for better visualisation for the whole team.

Conclusion

We have seen and understood how important DevSecOps is in 2020. It is required on our whole pipeline and overlooking it is inviting danger because of various attacks. We looked at the questions that are answered while setting a cluster and how can we design our DevSecOps pipeline. Hopefully we will be getting more advanced tools that will be performing multiple tasks at once in the coming future!

References

knoldus