A container moves from build and signing through a verification gate into a runtime cluster.
    Back to Blog
    SecurityMarch 8, 2026

    Securing Your Kubernetes Supply Chain

    By Vishkar Platform Engineering Team

    How Wide Is Your Kubernetes Supply Chain Attack Surface?

    Software supply chain attacks increased 742% between 2019 and 2022, and Sonatype's 2024 State of the Software Supply Chain report found that malicious open source packages grew 156% year-over-year — with over 512,000 malicious packages detected to date (Sonatype, 2024). The SolarWinds and Log4Shell incidents made the threat visceral for engineering leadership.

    The Kubernetes supply chain in particular — from source code through to running workload — has more attack surface than most teams have formally mapped.

    The chain looks like this: developer workstation → source code repository → build system → container image → registry → Kubernetes admission → running container. A compromise at any point can result in malicious code running in production. This post maps the controls that close the most meaningful gaps.

    TL;DR: Kubernetes supply chain security requires controls at every stage: image signing (Cosign), SBOM generation (Syft/Grype), admission policy enforcement (Kyverno or OPA Gatekeeper), hardened base images, secrets management via the CSI driver, and runtime anomaly detection (Falco). The Day 1 checklist at the end covers the controls any team can implement in a sprint.


    Why Sign Container Images with Cosign?

    A container image without a verifiable signature is a promise without a signature — you're trusting that what arrived in your registry is what your build system produced. The SolarWinds attack demonstrated that build systems themselves can be compromised. Image signing with Cosign (part of the Sigstore project) creates a cryptographic chain of custody from build to deployment.

    Cosign is now part of the Sigstore project, a Linux Foundation initiative backed by Google, Red Hat, and Purdue University (Sigstore, 2023).

    Signing an Image in CI

    # Install cosign
    brew install cosign  # or via GitHub releases for CI
    
    # Generate a key pair (for keyful signing; keyless is also supported)
    cosign generate-key-pair
    
    # Sign the image after push
    cosign sign --key cosign.key \
      your-registry.io/your-image:v1.0.0@sha256:<digest>
    

    The @sha256:<digest> reference is critical — you're signing a specific immutable digest, not a mutable tag. In CI, capture the digest from the docker push output and use it explicitly.

    For keyless signing (recommended for CI/CD), Cosign integrates with OIDC identity providers like GitHub Actions and Google Cloud:

    # Keyless signing via GitHub Actions OIDC — no key management required
    cosign sign --yes your-registry.io/your-image:v1.0.0@sha256:<digest>
    

    Verifying at Admission

    Verification happens at the Kubernetes admission layer (covered below). The policy checks that the image is signed by a trusted key before allowing it to be scheduled.


    What Is an SBOM and Why Does Kubernetes Need One?

    A Software Bill of Materials (SBOM) is a machine-readable inventory of every package and dependency in a container image. Executive Order 14028 (May 2021) mandated SBOMs for software sold to the US federal government (White House, 2021), accelerating adoption across the industry.

    For Kubernetes workloads, the SBOM answers: "when a new CVE is published, which of my running containers are affected?"

    Generating SBOMs with Syft

    # Install syft
    brew install syft
    
    # Generate SBOM for a container image (CycloneDX format)
    syft your-registry.io/your-image:v1.0.0 -o cyclonedx-json > sbom.json
    
    # Scan for known vulnerabilities with Grype
    grype sbom:./sbom.json
    

    Integrate this into your CI pipeline as a non-blocking step initially. Collect baseline data on your vulnerability posture before setting thresholds.

    SBOM Attestation

    Attach the SBOM to your image as a Cosign attestation so it travels with the image:

    cosign attest --key cosign.key \
      --predicate sbom.json \
      --type cyclonedx \
      your-registry.io/your-image:v1.0.0@sha256:<digest>
    

    Admission policies can then verify that a signed SBOM attestation exists before allowing the image to run.


    How Does SLSA Framework Map to Your Kubernetes Pipeline?

    SLSA (Supply-chain Levels for Software Artifacts) is a security framework from Google, now hosted by OpenSSF, that defines four progressive levels of supply chain integrity (SLSA framework, 2023). Each level maps directly to controls you may already be implementing.

    SLSA Level 1 — Build provenance. Your CI system generates a signed provenance document describing what inputs produced what outputs. This is the minimum bar for most regulated environments.

    SLSA Level 2 — Hosted build service. Builds run on a hosted, version-controlled CI system (GitHub Actions, Google Cloud Build, GitLab CI) rather than a developer's local machine. The provenance is signed by the build service itself.

    SLSA Level 3 — Isolated builds. The build process runs in an ephemeral, isolated environment with no persistent state between runs. This closes the class of attacks where a compromised build machine injects malicious code across multiple builds.

    For most Kubernetes teams, the practical path is: implement SBOM generation and Cosign signing (which together satisfy Level 2 provenance requirements), then work toward Level 3 by ensuring your CI runners are ephemeral and your build environment is reproducible. Full SLSA Level 4 compliance — hermetically sealed builds with two-party review — is an aspiration for most teams, not a near-term target.


    Kyverno vs. OPA Gatekeeper: Which Admission Controller?

    Admission controllers are the last line of defense before a workload runs. Both Kyverno and OPA Gatekeeper are CNCF projects; the choice comes down to your team's background and policy complexity.

    FactorKyvernoOPA Gatekeeper
    Policy languageKubernetes-native YAMLRego (custom DSL)
    Learning curveLow for k8s operatorsHigher (Rego is a new language)
    Mutation supportNativeVia separate mutation webhooks
    EcosystemGrowingMature, large library of policies
    Best fitTeams already fluent in YAMLTeams with complex policy logic

    A Kyverno Policy: Blocking Unsigned Images

    apiVersion: kyverno.io/v1
    kind: ClusterPolicy
    metadata:
      name: require-signed-images
    spec:
      validationFailureAction: Enforce
      background: false
      rules:
        - name: check-image-signature
          match:
            any:
              - resources:
                  kinds: [Pod]
                  namespaces: [production, staging]
          verifyImages:
            - imageReferences:
                - "your-registry.io/*"
              attestors:
                - count: 1
                  entries:
                    - keys:
                        publicKeys: |-
                          -----BEGIN PUBLIC KEY-----
                          <your cosign public key>
                          -----END PUBLIC KEY-----
    

    This policy blocks any Pod in production or staging namespaces from scheduling if its image from your registry is not signed with your Cosign key.


    Should You Use Distroless or Scratch Base Images?

    Distroless images (maintained by Google) contain only the application and its runtime dependencies — no shell, no package manager, no system utilities. The attack surface is dramatically reduced because there's less for an attacker to use if they achieve code execution.

    # Standard approach — smaller, no shell
    FROM gcr.io/distroless/java17-debian12
    COPY --from=build /app/service.jar /app/service.jar
    CMD ["/app/service.jar"]
    

    The tradeoff: debugging is harder. There's no sh to exec into, no curl to test connectivity. The operational pattern is: use a standard image in development and CI (for debugging capability), use distroless in staging and production (for the reduced attack surface).

    For Go binaries, scratch (completely empty) is often viable since Go compiles to a static binary with no runtime dependencies:

    FROM scratch
    COPY --from=build /app/service /service
    ENTRYPOINT ["/service"]
    

    The limitation of scratch: no CA certificates for TLS verification by default. Copy them from the build stage: COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/.


    Secrets Management: Why Kubernetes Secrets Are Not Enough

    Kubernetes Secrets are base64-encoded, not encrypted. By default, they're stored in plaintext in etcd. Anyone with etcd access — or any workload with a sufficiently permissive ClusterRole — can read them. This is well-documented but often not acted on.

    The right solution is to store secrets in a purpose-built secrets manager (HashiCorp Vault, AWS Secrets Manager, GCP Secret Manager) and sync them into pods using the Secrets Store CSI driver.

    # SecretProviderClass — maps Vault secrets to a volume mount
    apiVersion: secrets-store.csi.x-k8s.io/v1
    kind: SecretProviderClass
    metadata:
      name: app-secrets
      namespace: production
    spec:
      provider: vault
      parameters:
        vaultAddress: "https://vault.internal:8200"
        roleName: "payment-service"
        objects: |
          - objectName: "db-password"
            secretPath: "secret/data/payment-service"
            secretKey: "db_password"
    

    In the Pod spec:

    volumes:
      - name: secrets-store
        csi:
          driver: secrets-store.csi.k8s.io
          readOnly: true
          volumeAttributes:
            secretProviderClass: "app-secrets"
    

    The CSI driver fetches secrets at pod startup from Vault (or AWS/GCP), mounts them as files, and optionally syncs them as Kubernetes Secrets for environment variable access. Critically, the secret values never appear in etcd.


    Runtime Security with Falco

    Signing and admission policies prevent known-bad workloads from running. Falco detects anomalous behavior in running workloads — the behavior that indicates an attacker has already gained some access.

    Falco is a CNCF graduated project that watches Linux kernel syscalls via eBPF and alerts on rules matching suspicious patterns (CNCF Falco, 2024). For teams running high-throughput workflow automation on the same cluster, see our guide to scaling Argo Workflows in production — runtime security monitoring becomes especially important as job counts grow.

    # Custom Falco rule — detect shell spawned in container
    - rule: Shell Spawned in Container
      desc: Detect when a shell is spawned inside a running container
      condition: >
        spawned_process and
        container and
        proc.name in (shell_binaries) and
        not proc.pname in (shell_binaries)
      output: >
        Shell spawned in container
        (user=%user.name container=%container.name
         image=%container.image.repository:%container.image.tag
         shell=%proc.name parent=%proc.pname)
      priority: WARNING
      tags: [container, shell, mitre_execution]
    

    Key rules to enable on day one: shell spawning in containers, outbound connections from containers that shouldn't have external access, writing to sensitive directories (/etc, /usr), and privilege escalation attempts.


    Day 1 Hardening Checklist

    ControlToolEffort
    Enable image scanning in CIGrype or Trivy1 hour
    Sign all production imagesCosignHalf day
    Block unsigned images at admissionKyverno ClusterPolicyHalf day
    Switch to distroless base imagesDockerfile change1 day per service
    Replace Kubernetes Secrets with CSI driverVault + CSI driver2 days
    Enable Falco with default rulesetHelm chartHalf day
    Generate SBOMs in CISyft1 hour
    Enable audit logging on kube-apiserverCluster config1 hour
    Restrict pod capabilitiesPodSecurity admissionHalf day
    Enable network policies (default-deny)NetworkPolicy1 day

    These ten controls represent the most impactful sprint-sized security investment for a Kubernetes-based platform. They don't eliminate all risk, but they close the supply chain gaps that are most frequently exploited.


    Frequently Asked Questions

    Is keyless Cosign signing safe for production?

    Yes. Keyless signing uses short-lived OIDC tokens from your CI provider (GitHub Actions, GitLab CI, Google Cloud Build) to authenticate the signing event. The signature is recorded in Rekor, Sigstore's transparency log — publicly auditable and tamper-evident. The advantage over key-based signing: no long-lived key management. The consideration: you depend on the Sigstore infrastructure being available during signing.

    How do we handle image scanning without slowing CI?

    Run Grype or Trivy as a non-blocking step initially. Collect data on your baseline vulnerability posture. Set a threshold (e.g., block on CRITICAL severity) only after your team has a process for addressing findings. Blocking CI before that creates alert fatigue and workarounds. Use --ignore-unfixed to filter CVEs with no available fix.

    What's the difference between Kyverno and OPA Gatekeeper for our use case?

    If your team writes YAML daily (most k8s operators), Kyverno's native YAML policy syntax is faster to adopt. If you have complex policy requirements — multi-resource validation, custom logic across resources — OPA's Rego language is more expressive. We default to Kyverno for new clients and introduce OPA Gatekeeper when policy complexity outgrows Kyverno's model.

    Can Falco alert on container drift?

    Yes. Falco's container drift detection (available in newer versions with the drift flag) alerts when a new executable appears in a container's filesystem after it started — a strong indicator of a supply chain compromise or active attack. Enable it alongside your standard rules.

    Need help scaling your infrastructure?

    Vishkar delivers production-ready Cloud, DevOps & AI solutions for modern engineering teams.

    Schedule a Consultation