CYBER SECURITY • CLOUD AND MODERN INFRASTRUCTURE SECURITY

CI/CD Security — Explain CI/CD security concepts (least privilege, signing, scanning) (conceptual)

Securing the automated software delivery pipeline against supply-chain attacks and misconfigurations.

Historical Context & Motivation

The evolution of software delivery from manual, monolithic releases to fully automated Continuous Integration / Continuous Delivery (CI/CD) pipelines introduced transformative speed and consistency—but it also created a new class of attack surface. Before CI/CD became the norm, a developer would compile code on a local workstation, a QA engineer would manually test it, and an operations team would deploy it to production servers over a maintenance window. Each handoff was slow but involved a human checkpoint. When organizations began automating these stages through pipeline orchestration tools, they traded those manual checkpoints for scripted, credential-laden processes that execute without human review. The security implications were initially underestimated: pipeline runners were granted broad permissions, third-party dependencies were pulled without verification, and secrets were stored in plain-text configuration files. A growing catalogue of high-profile breaches—most notably the SolarWinds supply-chain compromise of 2020—demonstrated that adversaries could weaponize CI/CD infrastructure itself, injecting malicious code into the build process rather than attacking running production systems directly.

2001
Agile Manifesto & Early CI
The Agile Manifesto popularized iterative development. Martin Fowler and ThoughtWorks formalized Continuous Integration as a practice: developers merge code to a shared repository multiple times per day, triggering automated builds and tests. Security considerations at this stage were minimal.
2010
Rise of DevOps and CD
Tools like Jenkins, Travis CI, and later GitLab CI popularized fully automated delivery pipelines. The Continuous Delivery model emerged, enabling push-button deployments. Secrets management and runner isolation became early concerns.
2017
NIST 800-190 & Container Security
NIST published guidance on container security, acknowledging that CI/CD pipelines building container images required specific hardening—image scanning, registry authentication, and runtime constraints.
2020
SolarWinds Supply-Chain Attack
Attackers compromised SolarWinds' build system, injecting malicious code into Orion software updates distributed to ~18,000 organizations. This breach catalyzed industry-wide focus on build-pipeline integrity and software supply-chain security.
2021–Present
SLSA Framework & Sigstore
Google introduced the Supply-chain Levels for Software Artifacts (SLSA) framework, and the open-source Sigstore project made artifact signing accessible. Executive Order 14028 mandated SBOMs and secure software development practices for US federal suppliers.

The central question that CI/CD security addresses is deceptively simple: how do you ensure that the artifact reaching production is exactly what a trusted developer intended, built from verified sources, free from known vulnerabilities, and deployed through a pipeline that itself has not been tampered with? Answering this question requires a layered defense-in-depth strategy combining least privilege, cryptographic signing, and automated scanning—the three pillars we examine throughout this lesson.

Core Principles of CI/CD Security

Securing a CI/CD pipeline is fundamentally about controlling trust boundaries throughout an automated workflow. Every stage of the pipeline—source code retrieval, dependency resolution, compilation, testing, packaging, and deployment—represents a point where malicious modification could occur. The discipline of CI/CD security organizes its defenses around a set of interlocking principles, each addressing a distinct threat vector. These principles do not operate in isolation; rather, they form a mutually reinforcing security posture where the failure of one control is mitigated by the presence of others.

1

Least Privilege

Every pipeline component—runner, service account, API token—receives only the minimum permissions necessary for its specific task. If a build job only reads source code and writes to an artifact bucket, it should have no ability to modify IAM policies or access production databases. This limits the blast radius of any single compromise.
2

Artifact Signing & Verification

Cryptographic signatures applied to build artifacts (container images, binaries, packages) establish provenance and integrity. Downstream stages verify these signatures before proceeding, ensuring that no unauthorized modification occurred between pipeline stages.
3

Automated Scanning

Static application security testing (SAST), dynamic analysis (DAST), software composition analysis (SCA), and container image scanning are integrated directly into the pipeline. Builds are automatically blocked if critical vulnerabilities are detected, preventing insecure code from reaching production.
4

Secrets Management

Credentials, API keys, and certificates are never stored in source code or pipeline configuration files. Instead, they are injected at runtime from dedicated secrets vaults (e.g., HashiCorp Vault, AWS Secrets Manager) and scoped to the specific job that needs them, with automatic rotation policies.
5

Immutable & Auditable Pipelines

Pipeline definitions are version-controlled and treated as infrastructure as code. Changes require peer review, and every execution is logged with tamper-evident audit trails. This prevents unauthorized pipeline modifications and supports forensic analysis.
KEY TAKEAWAY
Think of a CI/CD pipeline as an automated assembly line in a pharmaceutical factory. Least privilege is like giving each station operator a keycard that opens only the equipment they need—preventing a packaging technician from accessing the chemical formulation room. Signing is the tamper-evident seal placed on each batch container as it moves between stations; if the seal is broken, the next station rejects it. Scanning is the quality control lab that tests samples at every stage, halting the line if contaminants are detected. No single control is sufficient on its own—together, they ensure the final product reaching consumers is safe and authentic.

The CI/CD Pipeline Security Architecture

To understand where security controls apply, it is essential to visualize the end-to-end CI/CD pipeline and identify the trust boundaries between stages. The diagram below presents a canonical pipeline architecture with the three core security controls—least privilege, signing, and scanning—mapped to their respective pipeline stages. Each stage runs in an isolated environment with its own scoped credential set, and artifacts are verified at every transition.

The diagram maps three security control layers—least privilege (blue), scanning (cyan), and signing (violet)—onto the five canonical pipeline stages. Dashed vertical lines represent trust boundaries (TB-1 through TB-4) where artifact handoffs occur and verification is critical. Each stage receives a uniquely scoped service account (SA) that cannot access resources belonging to other stages.

Several important observations emerge from this architecture. First, least privilege is applied uniformly across all five stages—every stage has its own narrowly scoped credential, and no single credential can traverse the entire pipeline. Second, scanning is concentrated in the middle stages (source through package) where code and dependencies are most amenable to analysis. Third, signing bookends the pipeline: developers sign commits at the source stage, the packaging stage signs the final artifact, and the deployment stage verifies that signature before releasing to production. This asymmetry reflects the distinct purposes of each control: privilege limits blast radius, scanning detects known-bad patterns, and signing asserts origin and integrity.

How the Three Pillars Work

Least Privilege in CI/CD

The principle of least privilege (PoLP) states that every entity in a system should operate with the smallest set of permissions necessary to perform its function. In a CI/CD context, this principle applies at multiple granularity levels: the pipeline runner's operating system user, the cloud IAM role or service account attached to each job, the Git access token used to check out source code, and the registry credentials used to push artifacts. A common antipattern is the "god token"—a single, broadly scoped credential shared across all pipeline stages. If any stage is compromised (e.g., through a poisoned dependency), the attacker inherits the full permission set. Proper PoLP implementation creates blast-radius compartments: compromising the test stage yields only test-environment credentials, insufficient to modify production infrastructure.

🔒 PoLP Implementation Checklist
Use ephemeral credentials with short TTLs (e.g., OIDC federation with cloud providers). Scope IAM roles per job, not per pipeline. Disable write access to the repository from CI runners. Use allow-lists for network egress so runners cannot exfiltrate data to arbitrary endpoints.

Cryptographic Signing and Verification

Artifact signing uses asymmetric cryptography to establish two properties: integrity (the artifact has not been modified since signing) and provenance (the artifact was produced by a trusted build system). The signing entity computes a cryptographic hash of the artifact, then encrypts that hash with its private key to produce a signature. Any consumer can verify the signature using the corresponding public key: they recompute the hash independently and compare it to the decrypted signature value. If they match, both integrity and provenance are confirmed.

DIGITAL SIGNATURE — SIGN
σ = Sign(SK, H(artifact))
where σ is the signature, SK is the signer's private (secret) key, and H is a cryptographic hash function (e.g., SHA-256). Sign typically denotes an RSA-PSS, ECDSA, or Ed25519 signing operation.
DIGITAL SIGNATURE — VERIFY
Verify(PK, σ, H(artifact)) → {true, false}
where PK is the public key corresponding to SK. The function returns true if and only if σ was produced by SK over the exact byte sequence of the artifact. Any modification to the artifact causes the verification to fail.

Modern tooling like Sigstore (comprising Cosign, Fulcio, and Rekor) simplifies this workflow by issuing short-lived signing certificates tied to OIDC identities and recording signatures in a transparency log. This eliminates the need for long-lived key management—a significant operational burden that historically deterred adoption. In a Sigstore-based pipeline, the CI system authenticates via OIDC, receives an ephemeral certificate from Fulcio, signs the artifact with Cosign, and the signature is recorded in the immutable Rekor log. Verification can occur at any point in the future by querying the log.

Automated Scanning Taxonomy

Scanning within CI/CD pipelines encompasses several complementary techniques, each targeting a different layer of the application stack. Static Application Security Testing (SAST) analyzes source code or bytecode without executing it, identifying patterns such as SQL injection sinks, buffer overflows, or insecure deserialization. Software Composition Analysis (SCA) inventories third-party dependencies and cross-references them against vulnerability databases like the National Vulnerability Database (NVD) or GitHub Advisory Database. Dynamic Application Security Testing (DAST) sends crafted HTTP requests to a running instance of the application, probing for runtime vulnerabilities. Finally, container image scanning inspects the layers of a Docker or OCI image for known CVEs in OS packages and language-specific libraries. Together, these techniques approximate coverage across the entire attack surface, though none is individually complete.

Scanning Techniques in Detail

Understanding the strengths and limitations of each scanning technique requires examining what each analyzes, when in the pipeline it executes, and what classes of vulnerabilities it can and cannot detect. The following diagram illustrates the scanning coverage across the software stack, from source code through runtime behavior.

The coverage map demonstrates that SAST excels at detecting code-level flaws like injection and hardcoded secrets, SCA targets known vulnerabilities in dependencies, DAST catches runtime issues like authentication bypasses, and image scanning covers OS-level misconfigurations and package vulnerabilities. No single technique provides complete coverage.
Comparison of CI/CD scanning techniques by stage, input type, and false positive characteristics
TechniquePipeline StageInputFalse Positive Rate
SASTBuild / TestSource code, AST, bytecodeMedium–High (requires tuning)
SCABuildpackage.json, pom.xml, go.sumLow (CVE matching is deterministic)
DASTTest (staging env)Running application endpointsMedium (depends on crawl coverage)
Image ScanPackageOCI image layers, SBOMLow (package version matching)

Worked Example: Securing a GitHub Actions Pipeline

Consider a development team that maintains a Python web application deployed as a Docker container to AWS Elastic Container Service (ECS). Their current GitHub Actions pipeline has several security weaknesses: a single long-lived AWS access key stored as a repository secret with administrator privileges, no dependency scanning, no image signing, and pipeline definition files editable by any contributor. We will walk through applying the three security pillars to harden this pipeline.

Hardening a CI/CD Pipeline with Least Privilege, Signing, and Scanning
1
Step 1 — Apply Least Privilege to CredentialsReplace the long-lived AWS access key with OIDC federation. Configure an AWS IAM OIDC identity provider trusting GitHub's token endpoint. Create three IAM roles with minimal policies: cicd-build-role (read-only access to the source S3 bucket), cicd-push-role (push-only to ECR), and cicd-deploy-role (update ECS service, no IAM or VPC modifications). Each job in the pipeline assumes only its designated role via aws-actions/configure-aws-credentials with the role-to-assume parameter. This eliminates long-lived secrets entirely and scopes permissions per job.
No long-lived credentials. Each job gets ephemeral tokens scoped to a single IAM role.
2
Step 2 — Integrate Automated ScanningAdd three scanning jobs to the pipeline. First, include github/codeql-action for SAST, configured to analyze Python source for injection vulnerabilities and insecure cryptographic usage. Second, integrate aquasecurity/trivy-action in fs mode during the build phase to perform SCA on requirements.txt. Third, after the Docker image is built, run Trivy again in image mode to scan OS packages and Python dependencies baked into the container. Configure all scanners to use exit-code: 1 for critical and high-severity findings so the pipeline fails and blocks deployment.
SAST (CodeQL), SCA (Trivy fs), and image scanning (Trivy image) all gate the pipeline. Critical findings block merge.
3
Step 3 — Sign and Verify the Container ImageAfter the image passes all scans, use sigstore/cosign-installer and invoke cosign sign with the --identity-token flag, leveraging the GitHub Actions OIDC token as the signing identity. This produces a keyless signature recorded in the Rekor transparency log. In the deploy job, before updating the ECS task definition, run cosign verify with --certificate-identity matching the expected workflow path and --certificate-oidc-issuer set to GitHub's token URL. If verification fails, the deploy job aborts.
Keyless signing via Sigstore. Deployment is gated on successful signature verification against the transparency log.
4
Step 4 — Harden Pipeline GovernanceProtect the workflow definition files by enabling GitHub's CODEOWNERS file to require security-team review for changes to .github/workflows/. Enable branch protection rules requiring signed commits on the main branch. Pin all third-party actions to specific commit SHAs rather than mutable tags (e.g., actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 instead of actions/checkout@v4) to prevent supply-chain attacks via tag reassignment.
Pipeline-as-code with mandatory review. All action references are SHA-pinned. Signed commits enforced.

Strengths, Limitations, and Trade-offs

Each of the three security pillars introduces operational trade-offs that engineering teams must carefully balance against their risk tolerance and velocity requirements. An overly restrictive pipeline can slow development to a crawl, while an insufficiently hardened one can become the weakest link in an organization's security posture. The table below summarizes the primary strengths and limitations of each approach.

Comparison of strengths and limitations for the three CI/CD security pillars
Security ControlStrengthsLimitations
Least PrivilegeLimits blast radius of compromised credentials. Enables fine-grained auditing. Aligns with zero-trust principles. OIDC federation eliminates long-lived secrets.Complex IAM configuration; role proliferation can create management overhead. Debugging permission errors slows development. Ephemeral credentials may cause intermittent failures if TTLs are too short.
Artifact SigningCryptographically verifiable provenance. Detects tampering between pipeline stages. Transparency logs enable audit. Keyless signing (Sigstore) reduces operational burden.Does not assess the quality or security of the signed artifact—only its origin. Key management (for non-keyless flows) is error-prone. Requires infrastructure for verification enforcement.
Automated ScanningCatches known vulnerabilities before production. Scales consistently across repositories. Provides auditable compliance evidence. SCA covers transitive dependencies.Cannot detect zero-day vulnerabilities or business logic flaws. False positives cause alert fatigue if not tuned. DAST requires a running environment, adding infrastructure cost. Scan times can bottleneck pipeline throughput.
⚖️ KEY TAKEAWAY
CI/CD security controls behave like the layers of a medieval castle's defenses. Least privilege is the series of locked gates with different keys—if an attacker breaches the outer wall, they still cannot access the treasury. Signing is the royal seal on dispatches—it proves the message came from the king, but says nothing about whether the order is wise. Scanning is the patrol guard who inspects incoming wagons for contraband—effective against known threats, but unable to detect a novel weapon disguised as grain. The castle is safest when all three defenses operate in concert.

Connection to Advanced Frameworks: SLSA and Zero Trust

The three foundational concepts covered in this lesson—least privilege, signing, and scanning—serve as building blocks for more comprehensive security frameworks that are increasingly adopted in enterprise environments. Two frameworks deserve particular attention: the Supply-chain Levels for Software Artifacts (SLSA) framework developed by Google, and the application of Zero Trust Architecture principles to CI/CD infrastructure.

Foundational concepts from this lesson mapped to advanced SLSA and Zero Trust frameworks
ConceptFoundational (This Lesson)Advanced (SLSA / Zero Trust)
Least PrivilegeScoped IAM roles per pipeline job; OIDC federation for ephemeral tokens; minimal network egressZero Trust: every request between pipeline components is authenticated, authorized, and encrypted—even within the same network. Workload identity replaces static credentials entirely.
SigningImage-level signing with Cosign/Sigstore; signed commits; transparency loggingSLSA Level 3+: build platform generates non-falsifiable provenance attestations. Hermetic builds ensure no network access during compilation. SLSA Level 4: two-party review of all changes.
ScanningSAST, SCA, DAST, and image scanning integrated into pipeline jobs with severity-based gatingContinuous verification in production (runtime SBOM monitoring, admission controllers in Kubernetes that verify signatures and scan results before pod scheduling).
Pipeline IntegrityCODEOWNERS, branch protection, SHA-pinned actionsSLSA: pipeline definitions are stored in a separate, hardened repository with stricter access controls than application code. Policy-as-code engines (OPA/Gatekeeper) enforce constraints declaratively.

The SLSA framework organizes supply-chain security into four levels (SLSA 1 through SLSA 4), each representing an incremental hardening of the build process. At Level 1, a project simply documents its build process. At Level 2, the build service generates authenticated provenance metadata. At Level 3, the build platform itself is hardened—builds run in ephemeral, isolated environments with audited configurations. Level 4 requires two-person review and hermetic builds that prevent any network access during compilation, guaranteeing that the output is a deterministic function of the checked-in source code. The concepts you have learned in this lesson align primarily with SLSA Levels 2 and 3, and they establish the foundational competence needed to implement the full SLSA specification. As the industry moves toward mandatory SBOM (Software Bill of Materials) requirements—driven by regulatory mandates like Executive Order 14028 and the EU Cyber Resilience Act—understanding these CI/CD security fundamentals becomes not merely a best practice but a compliance obligation.

Practice Problems

PROBLEM 1CONCEPTUAL
A CI/CD pipeline uses a single AWS IAM user with AdministratorAccess for all pipeline stages. Explain, with reference to the principle of least privilege, why this is a security risk and describe a concrete remediation strategy.
PROBLEM 2BASIC CALCULATION
A container image has been signed with Cosign using an ECDSA P-256 key. The SHA-256 digest of the image is sha256:a1b2c3.... During deployment, the verification step computes a digest of sha256:d4e5f6.... What is the outcome of Verify(PK, σ, H(artifact)), and what does this indicate about the artifact's integrity?
PROBLEM 3INTERMEDIATE
A development team integrates SAST, SCA, and image scanning into their pipeline but omits DAST. Their application is a REST API with role-based access control (RBAC). Identify a class of vulnerability that their current scanning strategy is likely to miss, and explain why adding DAST would address this gap.
PROBLEM 4APPLIED
Your organization uses GitHub Actions to build and deploy a microservices application across 12 repositories. Management requests that you implement a policy requiring all container images to be signed and verified before deployment to the Kubernetes cluster. Design a solution that enforces this policy at the cluster level (not just in the pipeline) and explain why pipeline-only enforcement is insufficient.
PROBLEM 5CRITICAL THINKING
Consider the SLSA framework's requirement for "hermetic builds" at Level 4, where the build process has no network access and all dependencies must be pre-fetched. Analyze the tension between this requirement and the operational reality of modern software development (frequent dependency updates, large transitive dependency trees). Propose an architecture that satisfies hermetic build requirements while remaining practically maintainable, and discuss any residual risks.

Lesson Summary

CI/CD pipelines automate the journey from source code to production, but their automation introduces attack surfaces at every stage. This lesson examined three foundational security controls that, when layered together, provide robust defense-in-depth. Least privilege constrains each pipeline stage's permissions to the minimum necessary—eliminating "god tokens" in favor of scoped, ephemeral credentials via OIDC federation and per-job IAM roles, thereby limiting the blast radius of any compromise. Cryptographic signing establishes artifact provenance and integrity through digital signatures (leveraging tools like Sigstore/Cosign) and transparency logs, ensuring that only artifacts produced by trusted build systems reach production.

Automated scanning—encompassing SAST, SCA, DAST, and container image scanning—detects known vulnerabilities across the full application stack, though no single scanner provides complete coverage. These three pillars form the conceptual foundation for advanced frameworks like SLSA and Zero Trust Architecture, which extend these controls with hermetic builds, non-falsifiable provenance attestations, and continuous runtime verification. Additionally, governance measures—SHA-pinned actions, CODEOWNERS review, and signed commits—protect the pipeline definition itself from unauthorized modification. Mastering these concepts prepares you to design and audit secure software delivery systems in any cloud-native environment.

Varsity Tutors • Cyber Security • CI/CD Security — Explain CI/CD security concepts (least privilege, signing, scanning) (conceptual)