Hi, HackerNoon! My name is Sofia, and I am a DevOps/Cloud engineer. I decided to participate in the contest by HackerNoon and Aptible.
In this article, I will talk about the features of the DevSecOps pipeline and the concept of Shift Left. You will learn about the main stages of the DevSecOps pipeline, automated security checks in software development, and free and open-source tools. You'll also find tips to help you detect vulnerabilities earlier and improve application security.
This article will help you assess the maturity of your DevSecOps pipeline, develop a roadmap for its development, choose the right tools for each task, and better understand how to manage projects following the DevSecOps philosophy.
The main goal of the DevSecOps methodology is to introduce automated security checks into the DevOps pipelines, i.e., into the software development process itself.
Not so long ago, information security specialists conducted tests after completing the development process. This approach is inefficient - if errors are discovered during security testing, the entire development cycle has to be restarted. This is time-consuming and expensive.
Take a look at the image below. You can see that the cost of error correction increases with each step.
It costs almost nothing to fix security issues discovered during development and functional testing. All necessary changes can be made to the source code immediately and sent for rechecking.
Fixing problems at the artifact build stage is at least twice as expensive. You will have to make changes to the build process, for example, edit the Dockerfile, which means you will need the help of DevOps engineers.
If an error is detected during integration testing, it will be 10 times more expensive to fix it. In this case, you must restart the development cycle and involve developers, DevOps engineers, and testers.
Security problems detected at the deployment stage can lead to user data leaks. The company can receive millions of dollars in fines and damage to its reputation, which means the cost of a mistake increases hundreds of times.
Hence, the main conclusion is that safety checks should be performed as early as possible. If you visualize it, move them to the left side of the Pipeline. This is the concept of Shift Left, which security experts love to talk about so much.
DevSecOps pipelines are an automated chain of processes and tools that build, test, and deliver applications in a production environment and secure them at every stage.
The image above shows the DevSecOps Pipeline structure with all the main phases of security checks. Here are a few words about each of them:
Next, let's take a closer look at what these checks are and what tools are used to perform them.
Pre-commit checks allow you to analyze the source code on the developer's machine before committing changes to the local copy of the repository. If any of the statements returns an error, the commit is not performed. In this case, the developer must fix the mistake and commit again.
This check avoids the situation when unchecked code, for example, with unencrypted secrets, gets into the repository.
For performing pre-commit source code checks, it is necessary to install tools on developers' local machines. This approach has not only advantages but also disadvantages. For example, environmental differences: different versions of the instruments, various operating systems, and even processor architectures.
If developers use different versions of pre-commit tools, the results of checking will differ, and this may make it challenging to work together. Consider this when implementing pre-commit checks within a team or across the company.
Many open-source tools can be used to set up pre-commit checks:
These are great tools for pre-commit checks.
In the pre-build phase, White Box Testing is performed. These checks are used to analyze the source code, like in the previous step. In this case, the application is a "white box" because we know and understand its architecture and internal structure.
There are several types of pre-build checks:
Now, let’s discuss them in detail.
Secret Detection is an automated check that detects unencrypted sensitive information: unencrypted secrets in source code that have entered a version control system.
Pre-build checks are performed after the source code has entered the repository of the version control system. Therefore, all unencrypted sensitive data in the storage can potentially be accessed by attackers, for example, if the repository's contents are leaked.
In addition, the process of implementing secret-detection checks may occur not from scratch but in an evolving project. In this case, unencrypted secrets may be found in old commits and different repository branches.
To solve these problems, we need to do many different things. For example, we must clean repositories of unencrypted secrets or implement various secret management tools like Hashicorp Vault.
Secret Detection can be configured using
Static Application Security Testing (SAST) is a test when analyzers do not just check syntactic correctness but also measure code quality with the help of unique metrics. The main task of SAST scanners is security testing.
In particular, SAST-analysers contain source code for common vulnerabilities, for example, some of the
SAST analysis is called White Box Testing because the analyzer can access the application's internal structure. It is important to note that analyzers check the source code without running it, so they may generate false positives and fail to detect some vulnerabilities.
For this reason, you should not limit yourself to SAST analysis only. It is better to approach the issue comprehensively and use different types of analysis: SCA, DAST, IAST, and OAST.
Proprietary solutions:
The free solution is GitLab SAST.
Software Composition Analysis (SCA) is a methodology that secures applications by analyzing their open-source components.
SCA scanners look for outdated dependencies that contain known vulnerabilities and exploits. In addition, some SCA tools can determine the license compatibility of components and the risks of license infringement.
Source SCA analyses the source code and, more specifically, the application dependencies defined in the source code. This analysis is often referred to as Dependency Scanning.
SCA allows you to detect an issue where a vulnerability in one component can lead to security problems in all applications.
A good example is
Commercial solution with free pricing plans:
As part of GitLab (available in Ultimate-version only), you can use
The post-build phase comes after artifacts have been built from source code in the CI Pipeline: a Docker image, an RPM package, or a JAR archive. With post-build checks, you can analyze the dependencies in these binary artifacts.
Binary SCA analysis involves inspecting binary artifacts such as Docker images, RPM packages, and JAR/WAR/EAR archives. It is also often referred to as Container Scanning. It makes sense to run it when the binary artifacts are built, i.e., not before the post-build stage.
There are some exciting features when working with Docker images. Binary SCA analyzers check layers of Docker images and look for them as hash sums in public vulnerability databases such as
Some of the analyzers can not only find vulnerable components but also suggest a fix, for example, by specifying the minimum required version of a component with an already fixed vulnerability.
The free solution is
Open Source solutions:
Docker Registry with built-in analyzers -
At this stage, dynamic Gray Box Testing and Black Box Testing are performed. When the application's internal structure is partially or wholly unknown, these security checks are performed by emulating the actions of an attacker who finds vulnerabilities and tries to "break" the application by exploiting them. Let`s briefly discuss each of them: DAST, IAST, and OAST.
DAST scanners automatically test applications by simulating external attacks through various vulnerabilities. The application is a black box for the analyzer; nothing is known about it.
For DAST checks, it is necessary to have a running instance of the application available for the scanner. Moreover, the closer the parameters of the test instance of the application are to the production installation, the fewer false positives there will be.
For example, suppose you have deployed a test application instance accessible only via HTTP protocol, but in production, the application is accessible only via HTTP protocol.
In that case, the DAST scanner will generate some errors related to the lack of traffic encryption between the client (analyzer) and the server (application instance).
Tools that are worth your attention:
Great, move on.
IAST (Interactive Application Security Testing) is a Gray Box Testing that combines the advantages and strengths of White Box Testing SAST and Black Box Testing DAST.
To collect all the advantages and eliminate the disadvantages of SAST and DAST methods, developers invented IAST - a hybrid mechanism combining these methods. It increases the accuracy of dynamic testing because it gives more information about the application operation through code analysis.
It is worth remembering that besides its advantages, IAST has limitations. The most basic one is the dependence on the language in which the application under test is written. IAST solutions work at the application level and require access to the executable code to analyze its behavior.
This means that IAST solutions must be able to understand the programming language in which the application is written. It should be noted that support for a particular IAST solution may be better implemented for some languages than others.
IAST analysis also takes a long time. It depends on many factors, such as the size and complexity of the application, the number of external dependencies, and the performance of the IAST tool used.
Besides, the analysis process does not scan the code itself but checks only those fragments that are directly executed. Therefore, IAST analysis is best combined with functional testing when you can test as many application scenarios as possible.
Here are great tools for you:
Great, move on.
OAST (Out-of-band Application Security Testing) is a technique developed by
I recommend you:
Move on.
This is an essential stage in ensuring application security and operability. Unlike pre-commit checks, which are performed at the development stage, post-deploy checks allow you to identify possible problems already during application operation in the natural environment.
For detecting new vulnerabilities in time, it is necessary to perform regular artifact checks, including after an application has been deployed.
This can be done using special repositories or tools, such as
Another way to ensure security is to monitor the application itself. There are several technologies available for this purpose:
The main advantage of RASP over WAF is that it understands how the application works and detects attacks and illegitimate traffic. RASP can see not only typical attacks using signature matching but also attempts to exploit zero-day vulnerabilities by reacting to anomalies.
Unlike WAF, RASP works within and with the application. WAF can be fooled. If an attacker changes the application code, WAF cannot detect it because it does not understand the execution context.
RASP has access to diagnostic information about the application, can analyze it, detect anomalies, and block attacks.
RASP technology has a specialty of focusing on preventing attacks by default. The system does not require access to the source code.
I recommend you:
Great, move on.
At different stages of the Pipeline, I use many Application Security Testing/DevSecOps analyzers. Each of them generates a report in its own format, and some of them generate so-called False Positives. Because of this, it isn't easy to analyze the security of an application as a whole.
To effectively analyze vulnerabilities and manage the remediation process, specialized Vulnerability Management tools, often referred to simply as Security Dashboards, are used.
Security Dashboards solve the problem by delivering the results of DevSecOps analyses in a unified and easy-to-analyse form. In this way, security engineers can see what issues exist, which ones are most critical, and which ones need to be addressed first.
A wide range of tools are usually used as Security Dashboards: for example, classic SOAR/SIEM systems and the specialized DevSecOps orchestrator AppSec.Hub from Swordfish Security or the open-source vulnerability management toolkit DefectDojo.
DefectDojo is a widespread tool. It is widely used even in enterprise companies. However, despite its popularity and solid age, this tool occasionally has some initial-level defects when contributors break the basic functionality in the commit.
However, what is nice is that DefectDojo developers and maintainers help to sort out the complexities. DefectDojo developers are very responsive people - we recommend contacting them directly via Issues on GitHub.
Once again, here is a quick recap of what was in the article.
I explained what the Shift Left concept is and how it helps reduce the cost of bug fixes and development time: the earlier in the development process you start security checks, the better.
Then, I deconstructed the DevSecOps Pipeline structure and looked at what security checks are performed at each stage of the Pipeline:
Now, you understand how the DevSecOps Pipeline works. Now, you can assess the maturity of your DevSecOps pipelines, develop a roadmap for its development, and choose the right tools for each task.