Skip to content

Security & Compliance in CI/CD

Security in CI/CD is not just about scanning code - it’s about controlling who can act on pipeline resources, what those actions can produce, and proving the integrity of every artifact that reaches production. This matters especially in regulated industries, but these controls are good engineering practice for any team.


Telemetry is what makes advanced deployment strategies - Canary rollouts, A/B tests, drift detection - actually work. Without measurable signals, you can’t know if a deployment is succeeding or failing.

Telemetry spans five phases of the pipeline:

PhaseWhat to measure
CodePR review time, branching frequency, code coverage, merge conflicts
BuildArtifact build time, dependency download duration, SBOM generation, vulnerability count
TestTest suite size, failure rate, flaky test rate, test duration
DeployPipeline execution time, deployment duration, environment provisioning time, rollback frequency
Post-deployError rates, incident frequency, user behavior signals, live performance metrics

Two open standards normalize this data across heterogeneous toolchains:

  • CDEvents - A specification for event categories emitted across all pipeline phases (Source Code Control, CI, CD events). SDKs integrate with common build and deployment systems, ensuring signals are collected uniformly regardless of the underlying tool.
  • SLSA (Supply-chain Levels for Software Artifacts) - A security-focused standard for build-phase telemetry. Covers artifact provenance and SBOM generation, allowing teams to answer “where did this artifact come from and what’s in it?”

CI/CD pipelines touch production systems. Without strict access controls, a misconfigured permission or a well-meaning shortcut can bypass the safeguards your deployment strategies were designed to provide.

SoD divides critical tasks across different individuals or systems so that no single person has end-to-end control over the pipeline. A typical SoD model:

RoleWhat they can do
DeveloperCommit code, open pull requests
QA TeamApprove builds, run test sign-off
Release ManagerTag versions, approve production deployments
Operations TeamMonitor live environment, trigger rollbacks

Segregation of Duties model across pipeline roles

No single role crosses into another. A developer cannot approve their own PR to production; a release manager cannot modify test results.

RBAC enforces SoD programmatically by answering: “Who can perform what actions on which resource?” Rather than managing permissions per individual, RBAC assigns permissions to roles - groups of related responsibilities - and attaches users to those roles.

A typical CI/CD RBAC hierarchy:

RoleTheir projectOther projects
Platform / SRE TeamFull admin - manage runners, secrets, platform configRead access across all projects for visibility
Team LeadManage pipelines, approve deployments, configure environmentsRead access to observe other teams’ pipelines
DeveloperTrigger pipelines, update pipeline config, read logsRead access only - cannot modify other teams’ pipelines

Examples in practice:

  • The QA team has pipeline run permissions on staging - but not production.
  • Only Release Managers can approve deployment to the main branch.
  • Developers can read pipeline logs but cannot modify environment configurations.

RBAC prevents the most common pipeline accidents: accidental production deploys and untested code bypassing staging.

For high-risk actions that automated checks alone cannot validate, approval flows act as explicit human gates. Common use cases:

  • Merging to a protected branch (e.g., release/)
  • Emergency hotfixes to live production
  • Infrastructure changes above a defined cost threshold

Approval flows integrate directly into pipeline definitions and block execution until a designated reviewer signs off.

Where RBAC controls who can act, OPA controls what those actions can produce. OPA is an open-source policy engine that evaluates declarative rules tied to pipeline events.

OPA can be hooked into any pipeline phase:

  • Build phase: Deny a build if it violates semantic versioning schema or lacks required metadata tags.
  • Deploy phase: Reject a deployment if the artifact was not signed or doesn’t have an SBOM attached.
  • Infrastructure phase: Block a Terraform plan if it would expose a security group to 0.0.0.0/0.

Domain-Driven CI/CD

Domain-Driven Design (DDD) is a software design approach that organizes code around the actual complexity of the problem it is solving - not around technical layers. It enforces a shared vocabulary (ubiquitous language) across developers, domain experts, and stakeholders, and divides large problem spaces into clearly bounded independent areas (bounded contexts).

In a CI/CD context, DDD maps perfectly: each bounded context becomes a deployable microservice with its own pipeline, tests, and deployment lifecycle. The organizational boundary and the deployment boundary match.

The Three Layers of a Domain-Driven Pipeline

Section titled “The Three Layers of a Domain-Driven Pipeline”

The Three Layers of a Domain-Driven Pipeline

LayerWhat it covers
DomainCore DDD concepts - ubiquitous language, bounded contexts, shared kernels, aggregates, domain events
CIStatic analysis, automated unit and integration tests, artifact creation
CDEnvironment provisioning, configuration management, system testing, controlled production release
BenefitWhat it means in practice
Improved communicationShared ubiquitous language bridges the gap between developers and domain experts - requirements are less likely to be misunderstood in code
Reduced couplingBounded contexts prevent logic from bleeding across domains, reducing the blast radius of any single change
Targeted scalabilityCI/CD processes align with domain boundaries, so individual services scale independently without touching the broader system
Faster and safer deliveryCI/CD pipelines per bounded context support feature toggles, canary releases, and blue-green deployments per service, not per monolith
Simplified troubleshootingWhen an issue occurs, the bounded context that owns it is immediately clear

Regulation actions - code reviews, security scans, compliance audits, mandatory approvals - are required in regulated sectors but create natural friction in CI/CD. They involve manual intervention or external verification, which conflicts with the CI/CD goal of fast, frequent delivery.

Regulation Actions

DDD offers a structured way to integrate compliance without destroying pipeline velocity, by applying five core principles:

DDD PrincipleRole in compliance
Ubiquitous LanguageRegulatory requirements are named and documented in the same terms used in code and pipeline configuration - making automation of compliance checks unambiguous
Bounded ContextsRegulation actions are scoped to specific contexts, avoiding system-wide compliance bottlenecks. Rigor is calibrated to the context’s actual regulatory exposure
Strategic DesignCategorizes the domain into core, supporting, and generic subdomains. Ensures compliance effort is proportional to business risk - avoiding over-engineering in low-risk areas
Context MappingVisualizes how compliance controls in one context interact with - or depend on - adjacent contexts. Identifies and resolves cross-boundary compliance risks
Domain EventsCompliance-relevant actions emit domain events that automatically trigger downstream regulatory checks. The event log becomes the audit trail

These principles form a feedback chain: ubiquitous language shapes bounded contexts → bounded contexts inform strategic design → strategic design drives context mapping → context mapping identifies gaps that refine bounded contexts.


In regulated sectors, access control is not a bolt-on feature - it is woven into the domain model itself. The domain layer owns business logic; the application layer acts as a policy enforcement point that decides what each actor is allowed to do.

PatternHow it worksBest for
RBACPermissions are tied to organizational roles (Developer, Compliance Officer, Release Manager). Role changes update permissions automatically.Large organizations with defined role hierarchies
ABACPermissions are evaluated dynamically against a set of attributes - user characteristics, resource type, action, and environment context (e.g., time of day, data classification).Highly regulated domains requiring fine-grained, context-sensitive access

Embedding Access Control into DDD Components

Section titled “Embedding Access Control into DDD Components”
DDD ComponentHow it enforces access
Entities and Value ObjectsAccess rules are part of the model itself - a PatientRecord entity knows which roles can read or modify it
Aggregate RootsAct as transaction boundaries and security boundaries. All operations on an aggregate are checked before they are committed
RepositoriesReturn only the objects the caller is authorized to interact with - unauthorized data never enters memory
Bounded ContextsEach context defines its own access policy, preventing unauthorized access from propagating across domain boundaries

Compliance belongs in the pipeline configuration, not in a spreadsheet reviewed the week before an audit. Building compliant artifacts means embedding regulatory requirements into every stage of the CI/CD process.

StepWhat to do
1. Compliance requirements analysisIdentify the applicable regulations - GDPR, HIPAA, PCI DSS, FedRAMP. Document exactly what each mandates regarding encryption, access, logging, and data residency.
2. Compliance-aware domain modelingDesign entities and aggregates with data encryption, access control, and audit logging as first-class properties - not added afterward.
3. Pipeline configurationIntegrate compliance checks into the pipeline as non-negotiable gates: SAST (SonarQube), DAST (OWASP ZAP), dependency scanning, ComplianceAsCode.
4. Compliance-specific automated testsWrite tests that validate encryption behavior, access control logic, and data protection rules - not just functional behavior.
5. Continuous monitoring and reportingAuto-generate audit logs and compliance reports on every pipeline run. Violations surface immediately, not at audit time.
6. Deployment access controlsEnforce RBAC and mandatory approval workflows for environment promotions. No manual intervention bypasses the policy engine.
7. Documentation and traceabilityMaintain a clear chain from regulatory requirement → implemented feature → automated test → deployed artifact.
8. Continuous adaptationRegulations change. Build review cycles into the team’s calendar and update pipeline gates when requirements shift.

DDD is particularly valuable in industries where software failures have legal, financial, or safety consequences:

IndustryDDD application
Financial servicesA payment processing bounded context is completely isolated from account management and fraud detection. Domain services, aggregates, and value objects encode complex financial rules within that boundary.
HealthcareContext mapping separates patient records from treatment protocols - each with its own ubiquitous language and domain events. HIPAA controls are enforced at the bounded context boundary, not scattered across the system.
Government / Public sectorDomain-driven structure separates license application processing from compliance checking. Strategic and tactical DDD patterns produce architectures that meet current regulatory requirements while remaining adaptable to future legislation.

Performance Considerations

DDD adds modeling depth. CI/CD demands delivery speed. This tension is real and must be managed deliberately.

Common pitfalls:

PitfallWhat it looks like
Overly complex domain modelsModels become so granular that each integration test run takes minutes instead of seconds; the pipeline slows to a crawl
Underestimated learning curveTeams struggling with DDD concepts slow down delivery and introduce inconsistencies in the bounded context boundaries
Communication gapsThe pace of CI/CD outstrips the pace of domain workshops; the code diverges from the current business reality

Mitigation strategies:

  • Design for modular, independently testable components - each bounded context should be testable in isolation without running the entire system
  • Promote the same artifacts at every stage - no rebuilding between environments; what was tested in staging is exactly what ships to production
  • Commit frequently and in small units - the feedback loop only works if the feedback arrives fast; large commits delay diagnosis

End-to-End Integration Flow

Implementing DDD in a CI/CD pipeline requires deliberate alignment between software design and business requirements:

StepAction
1. Understand the domainWork with domain experts to map business processes. Define a ubiquitous language that is reflected in variable names, event names, and test descriptions.
2. Define bounded contextsPartition the domain model into logically independent segments. Each context becomes its own deployable microservice with its own database.
3. Automate domain-specific testingEvery commit triggers builds and tests. Include tests that validate business behavior - not just that the code compiles and the API returns 200.
4. Use feature toggles for continuous deploymentDeploy every successfully tested artifact to staging or production. Feature toggles decouple deployment from release - new behavior ships dark until the business is ready to expose it.
5. Implement observabilityTrack domain event flow in production. When observed behavior diverges from expected behavior, feed that back into domain model refinement.
6. Build a continuous learning cultureSchedule regular domain workshops and retrospectives. The domain model is a living document - it evolves as the business evolves.
7. Version control the domain modelTrack changes to bounded context definitions and interface contracts alongside code. The main branch always reflects the current canonical domain model.