Skip to content

DevOps CI/CD Security

CI/CD Security is the practice of embedding security controls throughout the Continuous Integration (CI) and Continuous Delivery/Deployment (CD) pipeline. The goal is to deliver software quickly without sacrificing security.

This concept is often referred to as DevSecOps, where security becomes a shared responsibility across development, operations, and security teams.


Modern applications are deployed frequently, sometimes multiple times per day. Without automated security controls:

  • Vulnerabilities can be introduced into production rapidly.
  • Secrets (API keys, passwords, tokens) may be exposed.
  • Malicious dependencies can enter the software supply chain.
  • Infrastructure misconfigurations can create security risks.
  • Attackers can compromise build systems and inject malicious code.

CI/CD security aims to detect and prevent these issues before deployment.


Developer
β”‚
β–Ό
Source Control (Git)
β”‚
β”œβ”€β”€ SAST
β”œβ”€β”€ Secret Scanning
β–Ό
Build Stage
β”‚
β”œβ”€β”€ Dependency Scanning
β”œβ”€β”€ SBOM Generation
β–Ό
Test Stage
β”‚
β”œβ”€β”€ Security Tests
β”œβ”€β”€ IaC Scanning
β–Ό
Container Build
β”‚
β”œβ”€β”€ Container Scanning
β–Ό
Deployment
β”‚
β”œβ”€β”€ Approval Gates
β”œβ”€β”€ Policy Enforcement
β–Ό
Production
β”‚
β”œβ”€β”€ Runtime Monitoring
β”œβ”€β”€ Threat Detection

Static Application Security Testing (SAST) analyses source code without executing it.

Detects:

  • SQL Injection
  • Cross-Site Scripting (XSS)
  • Hard-coded credentials
  • Authentication flaws
  • Insecure coding patterns
  • SonarQube
  • Checkmarx
  • Veracode
  • Semgrep
  • Microsoft Security Code Analysis

Developers sometimes accidentally commit:

API Keys
Passwords
Certificates
Database connection strings
JWT signing keys

Security scanners detect such secrets before code is merged.

  • GitGuardian
  • TruffleHog
  • GitHub Secret Scanning
  • Gitleaks

Example:

// Bad
string apiKey = "abc123-secret-key";

The pipeline should fail if this is detected.


Applications depend heavily on third-party libraries.

Example:

Newtonsoft.Json
Log4Net
EntityFramework

A vulnerable package can compromise the application.

  • Snyk
  • Dependabot
  • OWASP Dependency-Check
  • GitHub Advanced Security

Checks:

  • Known CVEs
  • Outdated packages
  • License violations

Attackers increasingly target software supply chains.

Examples:

  • Malicious package uploads
  • Build server compromise
  • Dependency hijacking

Mitigations:

  • Package signing
  • Trusted repositories
  • Dependency pinning
  • Build provenance verification

An SBOM is an inventory of every component used in the application.

Example:

Application:
β”œβ”€β”€ ASP.NET Core 9
β”œβ”€β”€ Serilog 4.0
β”œβ”€β”€ AutoMapper
└── Newtonsoft.Json

Benefits:

  • Faster vulnerability investigations
  • Compliance support
  • Supply-chain visibility

Tools:

  • Syft
  • CycloneDX
  • SPDX

Dynamic Application Security Testing analyses a running application.

Detects:

  • Authentication issues
  • Session vulnerabilities
  • XSS
  • Security misconfigurations

Tools:

  • OWASP ZAP
  • Burp Suite
  • Acunetix

Infrastructure definitions should be checked before deployment.

Example Terraform/Azure Bicep:

Azure Storage Account
Azure SQL Database
Kubernetes Cluster

Detects:

  • Publicly exposed databases
  • Weak network rules
  • Missing encryption
  • Excessive permissions

Tools:

  • Checkov
  • tfsec
  • Terrascan

Container images can contain vulnerabilities.

Example Docker image:

FROM ubuntu:22.04

The base image may include vulnerable packages.

Scanners analyse:

  • Operating system packages
  • Installed libraries
  • Known CVEs

Tools:

  • Trivy
  • Clair
  • Anchore
  • Microsoft Defender for Containers

Best practices:

FROM mcr.microsoft.com/dotnet/aspnet:9.0
RUN adduser appuser
USER appuser

Avoid:

  • Running as root
  • Unnecessary packages
  • Open ports not required

Before production deployment:

βœ“ Unit tests passed
βœ“ Security scans passed
βœ“ Vulnerabilities below threshold
βœ“ Approvals completed

The deployment should automatically stop if requirements are not met.


CI/CD systems should have only necessary permissions.

Bad:

Contributor access to entire Azure subscription

Better:

Deployment permission only
to specific resource group

Never store secrets in:

Git repositories
Build scripts
Configuration files

Use dedicated secret stores:

  • Azure Key Vault
  • HashiCorp Vault
  • AWS Secrets Manager

Example:

connectionString: $(SQL_CONNECTION_STRING)

The secret is injected at runtime.


Security should continue after deployment.

Monitor for:

  • Unusual logins
  • Privilege escalation
  • Malware
  • Container escapes
  • Suspicious network traffic

Tools:

  • Microsoft Defender for Cloud
  • Microsoft Sentinel
  • Falco
  • CrowdStrike

βœ… Shift security left

βœ… Automate all security scans

βœ… Scan every pull request

βœ… Use signed artifacts

βœ… Generate SBOMs

βœ… Rotate secrets regularly

βœ… Apply least-privilege access

βœ… Continuously monitor production

❌ Hard-code credentials

❌ Ignore dependency updates

❌ Deploy without security gates

❌ Run containers as root

❌ Give pipelines excessive permissions

❌ Rely solely on manual security reviews


1. Developer creates Pull Request
β”‚
2. SAST Scan
β”‚
3. Secret Scan
β”‚
4. Dependency Scan
β”‚
5. Build Application
β”‚
6. Create SBOM
β”‚
7. Container Scan
β”‚
8. Deploy to Test
β”‚
9. DAST Scan
β”‚
10. Approval Gate
β”‚
11. Deploy to Production
β”‚
12. Continuous Monitoring

CI/CD Security (DevSecOps) means integrating automated security checks into every stage of the software delivery pipeline, from code commit to production deployment. The objective is to identify vulnerabilities, misconfigurations, secrets, and supply chain risks as early as possible while enabling fast, reliable, and secure software releases.