Cybersecurity

DevSecOps: Bringing Security Into the Development Pipeline

Teams deploy dozens of times a day, and a security review at the end of the release cycle cannot keep up. DevSecOps puts automated security checks into every stage of the pipeline. Here is what a practical pipeline looks like in 2022, and how to roll it out without slowing developers down.

By EthicalHat Research · · 3 min read
Infographic: Security checks at every stage of the pipeline

A decade ago, many companies released software a few times a year. Security could review each release, run a penetration test and sign off. Today, most of the teams we work with deploy several times a day. A two-week security review at the end is not just slow. It no longer lines up with how software is delivered.

DevSecOps is the answer the industry has settled on: make security a set of automated, continuous checks built into the same pipeline that builds and ships code, owned jointly by development, operations and security.

The principle: move checks to where the work happens

The cheapest time to fix a vulnerability is minutes after it was written, while the developer still has the context. The most expensive time is after it has been exploited in production. DevSecOps moves as many checks as possible to the left of that timeline, without removing the checks on the right.

flowchart LR
  A[IDE &<br/>pre-commit] --> B[Pull<br/>request]
  B --> C[Build &<br/>package]
  C --> D[Deploy to<br/>staging]
  D --> E[Production<br/>runtime]
  A -.- A1[secrets, lint]
  B -.- B1[SAST, SCA, IaC]
  C -.- C1[image scan, SBOM, sign]
  D -.- D1[DAST, policy]
  E -.- E1[monitoring, WAF]

The building blocks

Secrets scanning. Credentials committed to Git are among the most common and damaging mistakes we find. Pre-commit hooks catch them before they leave the laptop, and server-side scanning catches the rest.

Software composition analysis (SCA). Most of your code is third-party dependencies. SCA tools compare them against vulnerability databases and suggest upgrades. After Log4Shell, this is non-negotiable.

Static application security testing (SAST). Analyses your own source code for patterns such as injection, unsafe deserialisation and path traversal. Modern tools like Semgrep and CodeQL are fast enough to run on every pull request.

Infrastructure-as-code (IaC) scanning. Terraform, CloudFormation and Kubernetes manifests define your security posture. Tools such as Checkov, tfsec and kube-linter catch public buckets and privileged containers before they exist.

Container image scanning. Base images carry operating system packages with their own vulnerabilities. Scan images at build time and in the registry.

Dynamic testing (DAST). Tools such as OWASP ZAP exercise the running application in staging to find issues static analysis cannot see, for example misconfigured headers and authentication flaws.

Artefact signing and provenance. After SolarWinds and Codecov, attackers are targeting the pipeline itself. Signing images with Sigstore's cosign and recording build provenance (the SLSA framework describes levels of assurance) let you prove that what runs in production is what your pipeline built.

A practical pipeline

Here is a condensed GitHub Actions workflow that covers the high-value basics:

yaml
name: ci
on: [pull_request, push]

jobs:
  security:
    runs-on: ubuntu-latest
    permissions: { contents: read, security-events: write, id-token: write }
    steps:
      - uses: actions/checkout@v3
        with: { fetch-depth: 0 }

      - name: Secrets scan
        uses: gitleaks/gitleaks-action@v2

      - name: SAST
        run: pipx run semgrep ci --config p/owasp-top-ten

      - name: IaC scan
        run: pipx run checkov -d infra/ --quiet

      - name: Build image
        run: docker build -t ghcr.io/example/api:${{ github.sha }} .

      - name: Scan image (fail on critical)
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: ghcr.io/example/api:${{ github.sha }}
          severity: CRITICAL
          exit-code: "1"

Signing and SBOM generation follow on the main branch once the image is pushed.

Rolling it out without a revolt

The fastest way to kill a DevSecOps programme is to switch on every scanner in blocking mode on day one. Developers get hundreds of findings, many of them false positives. The build goes red and someone disables the checks.

What works better:

  1. Start in report-only mode. Measure the baseline and tune the rules before anything blocks a merge.
  2. Block only on high-confidence, high-impact findings: leaked secrets, critical CVEs with a fix available, public storage buckets. Everything else becomes a ticket.
  3. Fix the backlog separately. Only fail builds on new issues introduced by the change. Track legacy findings as their own project.
  4. Put results in the pull request. Developers should see findings as review comments with a suggested fix, not in a separate security portal.
  5. Give teams a security champion. One developer per team who gets extra training and is the first point of contact scales far better than a central security team reviewing everything.
  6. Measure outcomes. Track time to fix critical findings and the number of vulnerabilities reaching production, not just the number of scans run.

What automation will not do

Scanners find known patterns. They do not understand your business logic, your authorisation model or how an attacker would chain three medium issues into a breach. Threat modelling during design, code review by people who know what to look for, and periodic manual penetration testing remain essential. DevSecOps frees those experts from catching trivial issues so they can focus on the hard ones.

If you are planning a DevSecOps rollout, our application security testing and secure code review services can help you choose tools, tune rules and train champions.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.