Your CI/CD pipeline helps you achieve fast and efficient application delivery — but it does not necessarily keep your applications secure.
While CI/CD offers many advantages, the speed and lack of manual oversight associated with CI/CD processes can also create new security risks. Those risks can be managed, but only if you place security front and center within your CI/CD pipeline.
Below, I explain common security oversights in CI/CD chains, and how to address them.
Securing CI/CD Shouldn’t Be an Afterthought
CI/CD pipelines are crucial to any team developing cloud-native applications. They are used to manage the software lifecycle end-to-end. This makes CI/CD pipelines an attractive target for attackers. By merely attacking the CI/CD pipelines, attackers can have access to private information contained in the applications they support. Applications can be disrupted and data leaks can happen, which, of course, is an absolute disaster for any organization.
Securing the CI/CD pipeline is an obvious top priority for DevOps teams. However, the process of applying security to the CI/CD pipeline isn’t straightforward. Developers should study their pipelines in-depth and understand what kind of information their pipelines ingest and their major vulnerabilities and then finding ways to eliminate them. Most of this can be done with strict implementation of DevSecOps practices, which makes sure security is at the core of an application. Developers should adhere to best practices for deploying and working with CI/CD pipelines to ensure they are protected from any security threat.
Threats to Your CI/CD pipeline
CI/CD pipelines are made up of a combination of various components that work with each other to provide efficient integration and deployment. These components consist of code and image repositories, build servers, containers and third-party tools. These components depend on trust relationships to communicate with each other. However, vulnerabilities to a CI/CD platform are easy to miss. Since the whole system has various dependencies and configurations, attackers can exploit seemingly secure resources and simply bring down the entire infrastructure.
Containers seem like a secure option for running applications because of their short lifespan and their isolated nature. However, attackers have been known to attack container images in the past. Containers are walled off from each other, but they are usually deployed on the same IP space. This means that if an attacker gains access to even a single container, they can then access any number of other containers in the cluster.
Containers have a short life span of 15-20 minutes, which is theoretically a great way to keep attackers from attacking any other component in a CI/CD pipeline. However, attackers can use that short time to access other vulnerabilities and download packages that they can use for more elaborate attacks.
Attackers can exploit the trust relationship between code repositories and servers to make changes in the code and commit them to the master, which can be extremely detrimental to an application. Developers tend to use credentials to various tools and resources through environment variables. Even though this is a better choice than hard-coding these credentials into the code, attackers can dump these variables to get all the information they need to exploit other resources. Attackers don’t have to launch a full-scale attack — they can simply access one of the various services in an application and use it to exploit expensive resources and launch various attacks on an application. Recycled code is convenient for developers, but attackers look to compromise open source code with vulnerabilities in order to leave applications that rely on them open to attack.
Securing the CI/CD Pipeline
It’s essential that DevOps teams study their pipeline and evaluate the attack surface and threats and come up with a set of best practices to adhere to while deploying a CI/CD pipeline. DevOps teams can take these steps to ensure security:
- Developers should begin by hardening their pipeline. This can be done by locking down systems that host repositories, configuration managers and the build servers;
- The entire pipeline should be monitored and there should be absolute visibility across various services to track down any anomalies instantly;
- Tools used in the pipelines should be audited arbitrarily and updated regularly. Access to repositories should also be audited and limited to avoid internal and external attacks;
- Keys, credentials, and secrets should be removed from scripts and protected by trusted secrets managers that secure them and audit them regularly;
- Access control should be implemented across the entire toolchain, ensuring that there is no anonymous or shared access to any service;
- Immutable logs should be maintained, which can then be checked periodically to trace back changes to their origin, making sure no unauthorized changes are made;
- Containers significantly increase the attack surface of any application, and it’s crucial that developers keep container security in mind from the very beginning;
- Code analysis tools should be used to ensure code is written using best practices, and that it doesn’t help open backdoors for attackers.
Conclusion
The unfortunate truth is the CI/CD pipeline wasn’t conceptualized with security as a foremost consideration. Speed and convenience were the chief goals. It’s therefore important developers carefully understand their CI/CD pipelines and make sure security is always given precedence. This approach may occasionally slow down development, but by keeping security in mind during development, DevOps, and more aptly, DevSecOps teams can avoid loss and damage when a threat eventually occurs.
Pingback: Bugs, Breaches, & More - ASW #75 - Security Weekly