Let’s map out the steps involved from taking a change from check-in to production and identify where we can insert security checks and controls. See the figure below for a model that explains how and where to add security checks into a Continuous Delivery workflow.
These are the steps before and until a change to software or configuration is checked in to the source code repo. Additional security checks and controls to be added here include the following:
Lightweight, iterative threat modeling and risk assessments.
Static analysis (SAST) checking in the engineer’s IDE.
Peer code reviews (for defensive coding and security vulnerabilities).
Commit stage (Continuous Integration)
This is automatically triggered by a check in. In this stage, you build and perform basic automated testing of the system. These steps return fast feedback to developers: did this change “break the build”? This stage needs to complete in at most a few minutes. Here are the security checks that you should include in this stage:
Compile and build checks, ensuring that these steps are clean, and that there are no errors or warnings.
Software Component Analysis in build, identifying risk in third-party components.
Incremental static analysis scanning for bugs and security vulnerabilities.
Alerting on high-risk code changes through static analysis checks or tests.
Automated unit testing of security functions, with code coverage analysis.
Digitally signing binary artifacts and storing them in secure repositories.
This stage is triggered by a successful commit. The latest good commit build is picked up and deployed to an acceptance test environment. Automated acceptance (functional, integration, performance, and security) tests are executed. To minimize the time required, these tests are often fanned out to different test servers and executed in parallel. Following a “fail fast” approach, the more expensive and time-consuming tests are left until as late as possible in the test cycle, so that they are only executed if other tests have already passed.
Security controls and tests in this stage include the following:
Secure, automated configuration management and provisioning of the runtime environment (using tools like Ansible, Chef, Puppet, Salt, and/or Docker). Ensure that the test environment is clean and configured to match production as closely as possible.
Automatically deploy the latest good build from the binary artifact repository.
Smoke tests (including security tests) designed to catch mistakes in configuration or deployment.
Targeted dynamic scanning (DAST).
Automated functional and integration testing of security features.
Automated security attacks, using Gauntlt or other security tools.
Deep static analysis scanning (can be done out of band).
Fuzzing (of APIs, files). This can be done out of band.
Manual pen testing (out of band).
Production deployment and post-deployment
If all of the previous steps and tests pass, the change is ready to be deployed to production, pending manual review/approvals and scheduling (in Continuous Delivery) or automatically (in Continuous Deployment). Additional security checks and controls are needed in production deployment and post-deployment:
Secure, automated configuration management and provisioning of the runtime environment.
Automated deployment and release orchestration (authorized, repeatable, and auditable).
Post-deployment smoke tests.
Automated runtime asserts and compliance checks (monkeys).
Blameless postmortems (learning from failure).
Depending on the risk profile of your organization and systems, you will need to implement at least some of these practices and controls. Leaders in this space already do most of them.