Securing Developer Workflows

April 02, 2019

As modern developers and DevOps teams are embarking on a quest for speed and reliability through automated CICD workflow pipelines for Kubernetes, enterprises still need to ensure security and regulatory compliance.

Related posts

A practical guide to operating Kubernetes the GitOps way

GitOps Part 4 - Application Delivery Compliance and Secure CICD

How secure is your CICD pipeline?

As modern developers and DevOps teams are embarking on a quest for speed and reliability through automated CICD workflow pipelines for Kubernetes, enterprises still need to ensure security and regulatory compliance.

A few weeks ago, Weaveworks and Snyk delivered a webinar, entitled Secure GitOps pipelines for Kubernetes. The theme of the webinar was on how to improve the security of your developer workflow - from Git to production.

Brice Fernandes, Customer Success Engineer at Weaveworks kicked off the talks with an in-depth look at what GitOps is and how it improves the overall security of your CICD pipelines.

How do you create a secure CICD pipeline?

In the typical CICD workflow pipeline, he said, the developer starts off on the left with read and write credentials to the code repository. The CI system reads the code repository for updates, creates a new entity, and writes that new entity into the container registry. The CI system may also have scripts that talk to the cluster API and modify the cluster itself. The scripts that are in place allow developers to deploy a new version or a new set of configuration files from the CI pipeline to the cluster. In addition to this, the developer may also have read/write credentials to push images to the container registry.

typical-cicd-pipeline-insecure.png<h2>The GitOps Model</h2><p>Brice then described GitOps: </p><ul><li>An operation model</li><li>Derived from computer science and operations knowledge</li><li>Technology agnostic (name notwithstanding)</li><li>A set of principles that discuss why rather than how it is done.</li><li>A way to speed up your team</li></ul><p>For teams who want to implement GitOps into their CICD pipelines, they will need to implement these four concepts into their developer pipeline. </p><h3>#1. The entire system is declaratively described.</h3><p>Kubernetes is one of many modern cloud-native tools out there that are declarative and that can be treated as code. Declarative means that configuration is guaranteed by a set of facts instead of by a set of instructions. With your application’s declarations versioned in Git, you have a single source of truth. Your apps can then be easily deployed and rolled back to and from Kubernetes. And even more critical to the GitOps story is that when disaster strikes, your cluster can also be dependably and quickly reproduced.</p><h3>#2. The canonical desired system state is versioned (with Git).</h3><p>With the declaration of your system stored in a version control system, and serving as your canonical source of truth, you have a single place from which everything is derived and driven. This trivializes rollbacks and you can use a git revert to go back to a previous state. With git’s excellent security guarantees, an SSH key signs commit to enforcing strong security guarantees about the authorship and the code’s provenance. </p><h3>#3. The ability to automatically apply approved changes.</h3><p>Once you have the declared state kept in git, the next step is to have the ability to automatically apply any state changes to your system. What’s significant about this is that you don’t need specific cluster credentials to make a change to your system. With GitOps, there is a segregated environment that the state definition lives outside of. This allows your team to separate what they actually do from how they are going to do it.</p><h3>#4. Software agents to ensure correctness.</h3><p>With the state of your entire system kept under version control, you can now employ software agents to inform you whenever reality doesn’t match your expectations. The use of diff and sync tools also ensures that your entire system is really self-healing. And by self-healing, we don’t mean when nodes or pods fail—those are handled by Kubernetes—but in a broader sense, like in the case of human error. In this case, software agents act as the feedback and control loop for your operations. </p><h2>GitOps in Practice</h2><p>Once you have all of these pieces in place, this is what your high-level workflows look like. There is the canonical source of truth kept under source control, developers then modify the canonical source of truth, and software agents are available that ensure the cluster’s correctness against the source of truth. </p>gitops-in-practice.png<h2>Security and The GitOps Developer Pipeline</h2><p>A GitOps pipeline contains a repository that represents your canonical desired state. Immediately, you start to see that the permissions to change the cluster exist only within the cluster and never leave the boundary of the cluster. The actual agent that’s modifying and updating the cluster is the software agent that lives inside of it. </p><blockquote>“Instead of you reacting to the outside world, it’s now your cluster reacting and changing to the outside world in a very structured way” - Brice Fernandes, Customer Success Engineer</blockquote><p>Instead of you reacting to the outside world, it’s now your cluster reacting and changing to the outside world in a very structured way. The operator can make changes to the canonical system’s repository and the system will react to changes in that repository. This allows your organization to set policies and other constraints that prevent an operator, for example, to make changes through the CI system. </p><p></p>gitops-pipeline-constraints.png<h2>Securing Git itself</h2><p>Since credentials are kept inside of the cluster, GitOps makes your CICD pipelines more secure. However, this does shift the burden of security onto git itself. Brice, followed up his discussion with a few of the common attacks on git: </p><ul><li>User impersonation</li><li>Git history rewrites</li><li>Lax settings for git’s security features</li><li>The use of deprecated software</li></ul><h2>Do you know which dependencies you have? </h2><p>Next up, Simon Maple, Director of Developer Relations (@sjmaple) at Snyk spoke on implementing an additional security layer to your pipeline that scans your dependencies for vulnerabilities. </p>snyk-security-testing.png<h2>Analyze your repo with Snyk</h2><p>Snyk statically analyzes your repo to find vulnerable dependencies you may be using and then helps you fix them. You can use Snyk’s UI to drill down on issues in your repos and keep users from accidentally adding vulnerable libraries by automatically scanning pull requests and failing checks when it finds one.</p>snyk-blog-resize.png<p></p><p>Did you find this helpful for improving your developer workflow? Check out more resources here.</p><p></p><p></p><p></p>


Related posts

A practical guide to operating Kubernetes the GitOps way

GitOps Part 4 - Application Delivery Compliance and Secure CICD

How secure is your CICD pipeline?

Download our whitepaper, Hardening Git for GitOps