Blog

CI/CD security tools for the cloud: securing pipelines on Google Cloud

Where CI/CD pipelines get attacked, the Google Cloud tool that closes each gap, and the AWS and open-source equivalents.

A CI/CD pipeline holds the keys to production. It can read your source, pull third-party code, build artifacts that run with real data, and push changes to live systems. That makes it one of the most valuable targets in a cloud account, and one of the least watched. This post walks through where pipelines get attacked, the Google Cloud tools that close each gap, the equivalent on AWS and in open source, and a checklist you can work through.

Where pipelines get attacked

It helps to think of the pipeline as a supply chain with seven links. Each one is a separate place to fail:

  • Source. A compromised developer account or an unreviewed merge puts malicious code into the main branch.
  • Dependencies. A typosquatted package, a hijacked maintainer account or a known-vulnerable library arrives through the package manager.
  • Build. A shared or long-lived build machine is tampered with, or a build step runs untrusted code with too many permissions.
  • Artifacts. An image is replaced in the registry, or one that was never built by your pipeline is pushed and deployed.
  • Deploy. Anyone with cluster access can run any image, skipping every check upstream.
  • Secrets. Service account keys and API tokens sit in CI variables, repo files or build logs, and outlive the people who created them.
  • Runtime. A vulnerability published after deployment affects images already running, and nobody notices.

The SLSA framework (Supply-chain Levels for Software Artifacts) gives a useful vocabulary for the build part of this. Its build levels move from simply having provenance, a signed record of how an artifact was built, up to builds on a hardened, isolated platform whose provenance cannot be forged by the build itself. You do not need to chase a level as a goal, but asking "can we prove where this image came from?" is the right question.

Google Cloud tools by stage

Build: Cloud Build and private pools

Cloud Build runs each build in a fresh, short-lived environment, which removes the "long-lived Jenkins box" problem. For builds that need to reach private resources, use private pools: dedicated workers inside a network you control, with no public IP if you want, so builds do not need your databases or internal registries exposed. Cloud Build can also generate build provenance for container images it builds, which is what lets you prove later that an image came from a specific trigger, commit and builder. Run each trigger as its own user-specified service account with only the roles that build needs, rather than a shared default account, and use build approvals for triggers that deploy to production.

Artifacts and dependencies: Artifact Registry and Artifact Analysis

Store images and packages in Artifact Registry, with separate repositories and IAM per environment so a development pipeline cannot overwrite a production image. Turn on Artifact Analysis vulnerability scanning: it scans images when they are pushed, covers both OS packages and common language packages inside the image, and keeps re-checking stored images as new vulnerabilities are published, which addresses the runtime gap above. Remote repositories in Artifact Registry can also act as a cached proxy for public package sources, so builds pull dependencies through one place you can audit.

Deploy: Binary Authorization

Binary Authorization is a deploy-time control for GKE and Cloud Run. You define a policy that says which images may run, typically "only images with an attestation from our build pipeline" and optionally "and a passed vulnerability check". An attestation is a signature over the image digest, created by the pipeline once checks pass. With enforcement on, an image pushed by hand, or built anywhere else, is rejected at deploy time. This is the control that makes every upstream check mean something, because without it a person with cluster access can bypass all of them.

Secrets: Secret Manager

Keep credentials in Secret Manager and have builds read them at run time, rather than storing them as CI variables or committing them. Cloud Build can inject Secret Manager values directly into build steps. Grant access per secret, not per project, enable versioning so you can rotate without breaking running services, and add a secret scanner such as gitleaks or your Git host's built-in secret scanning to catch anything that slips into a commit.

Identity: IAM and Workload Identity Federation

The single most valuable change for most teams is removing long-lived service account keys from CI. If your pipeline runs on GitHub Actions or GitLab CI, Workload Identity Federation lets the CI job exchange its own short-lived OIDC token for short-lived Google Cloud credentials. There is no JSON key to leak or rotate. Restrict the federation by repository and branch so only the main branch of the right repo can impersonate the deploy account. Once federation is in place, set the organization policy iam.disableServiceAccountKeyCreation so new keys cannot be created.

The older advice still holds where it applies: least privilege for every user and service account, conditional IAM bindings to limit access by resource or time, and multi-factor authentication (2-Step Verification) for every human account that can change the pipeline or production. What no longer applies is "rotate IAM passwords": on Google Cloud, people sign in with managed Google identities, and machines should use short-lived credentials, not keys.

Perimeter: VPC Service Controls

VPC Service Controls draw a perimeter around Google Cloud services such as Artifact Registry, Cloud Storage and Secret Manager. Even a stolen credential cannot copy data out of the perimeter to a project outside it. It takes planning to roll out, so start with dry-run mode and read the violation logs before enforcing.

Visibility: Cloud Audit Logs and Security Command Center

Cloud Audit Logs record who changed IAM policies, triggers, Binary Authorization policies and secrets. Admin Activity logs are always on; turn on Data Access logs for Secret Manager and other sensitive services. Route them to a separate project and set log-based alerts for the changes that should be rare, such as a new service account key, a Binary Authorization policy edit or a new owner on a project. Security Command Center then gives one view of misconfigurations, vulnerabilities and threats across the organization, so the findings from these tools do not live in five different consoles.

The same control on Google Cloud, AWS and open source

Most teams mix managed services with open-source tools, and many run more than one cloud. This table maps each control. A dash means we would normally use the open-source option in that column.

ControlGoogle CloudAWSOpen source
Image vulnerability scanningArtifact AnalysisAmazon Inspector (ECR scanning)Trivy, Grype
Dependency scanning (SCA)Artifact Analysis (language packages in images)Amazon InspectorOWASP Dependency-Check, Dependabot, Renovate
Static analysis (SAST)——Semgrep
IaC scanning——Checkov, Trivy (which absorbed tfsec)
Image signing and attestationBinary Authorization attestationsAWS SignerSigstore Cosign
Deploy-time policyBinary Authorization, Policy Controller—OPA Gatekeeper, Kyverno
SecretsSecret ManagerAWS Secrets ManagerHashiCorp Vault
Keyless CI authenticationWorkload Identity FederationIAM OIDC identity provider—
Audit trailCloud Audit LogsAWS CloudTrail—

The managed services win on effort: they are already wired into the registry, the IAM model and the audit logs. Open-source tools win on portability and on shifting checks earlier, because you can run Trivy, Semgrep or Checkov on a developer laptop and in a merge request, before anything reaches a registry.

A practical checklist

  1. Protect the main branch: required reviews, no direct pushes, and signed or verified commits where your Git host supports them.
  2. Remove service account keys from CI and switch to Workload Identity Federation, then block new key creation with organization policy.
  3. Give each pipeline its own service account with only the roles it needs, and separate build accounts from deploy accounts.
  4. Run builds in ephemeral environments (Cloud Build, or private pools when builds need private network access).
  5. Pull dependencies through Artifact Registry remote repositories and pin versions with lock files.
  6. Run SAST, dependency and IaC scans in every merge request, and fail the build on critical findings you have agreed to block on.
  7. Turn on Artifact Analysis scanning for every image repository.
  8. Generate build provenance and attest images that pass your checks.
  9. Enforce Binary Authorization on GKE and Cloud Run so only attested images can run.
  10. Store every credential in Secret Manager, scan commits for leaked secrets, and rotate anything that leaks.
  11. Enforce MFA for every human with access to the pipeline or production.
  12. Export audit logs to a separate project and alert on key creation, IAM changes and policy edits.

Where to start

If you can only do three things this quarter, do these, in this order. First, replace service account keys in CI with Workload Identity Federation; it removes the credential most likely to leak and is usually a day or two of work per pipeline. Second, turn on Artifact Analysis scanning and read what it finds before deciding what to block. Third, roll out Binary Authorization in dry-run mode, fix what it would have rejected, then enforce it.

Security controls also stick better when the delivery process itself is in code. In our work on repeatable delivery for an AdTech platform, moving infrastructure to Terraform and deployments to GitOps with ArgoCD made every change version controlled and traceable, which is the foundation that review rules, policy checks and audit trails build on. If you want help building or reviewing a secure pipeline, see our cloud & DevOps services.

Where to go from here

Doing this for real, and it is not going to plan?

Tell us where you are with it.