Container images are an important part of modern application deployment. Development teams build images, push them to container registries, and deploy them across Kubernetes clusters, cloud platforms, and production servers.
However, downloading a container image does not automatically prove that it came from a trusted source. An attacker could publish a modified image using a familiar repository name or replace an image tag with a different image.
This creates a software supply chain security challenge. Organizations need a reliable way to verify that a container image was produced by an authorized build process and has not been modified after signing.
Sigstore provides tools and infrastructure for signing and verifying software artifacts. Cosign is one of its main tools for working with container image signatures.
With Cosign, developers can sign container images, verify their signatures, and use keyless signing through OpenID Connect (OIDC). This makes it possible to establish trust in container images without manually managing long-lived signing keys in every CI/CD environment.
This article explains how container image signing works, how to use Cosign with Sigstore, how to implement keyless signing, and how to introduce signature verification into production deployment pipelines.
Why Container Image Signing Matters
A container image contains an application's executable code, dependencies, libraries, and runtime configuration. Once an image is published to a registry, deployment systems can download and execute it.
The problem is that a container registry does not automatically establish whether an image was created by an authorized developer or CI/CD pipeline.
For example, imagine an organization publishes an application image:
registry.example.com/payment-api:1.0
A deployment system pulls this image and starts it in a Kubernetes cluster.
If someone replaces the image behind the tag with a modified version, the deployment system may download and execute the replacement without knowing that anything changed.
Image signing helps address this problem.
A digital signature connects an image to a signing identity or cryptographic key. Before deployment, a verification process checks whether the signature is valid and whether it belongs to an identity the organization trusts.
Container image signing provides several benefits:
Helps verify the origin of container images.
Detects changes to signed image content.
Establishes trust between build and deployment systems.
Reduces the risk of deploying unauthorized images.
Supports software supply chain security policies.
Provides evidence that an image was signed by an expected identity.
Signing does not prove that an application is free from vulnerabilities or malicious code. It establishes the authenticity and integrity of the signed artifact. Organizations still need vulnerability scanning, code review, and build security controls.
Understanding Sigstore and Cosign
Sigstore is an open-source project focused on making software signing and verification easier.
It provides several components that work together to support software supply chain security.
Cosign is the command-line tool used to sign and verify container images and other artifacts.
Three important Sigstore components are:
Cosign
Cosign provides commands for signing container images, verifying signatures, and working with software attestations.
It supports several signing approaches, including keyless signing, local key pairs, and keys stored in supported key management systems.
Fulcio
Fulcio is Sigstore's certificate authority. In a keyless signing workflow, it issues a short-lived signing certificate after verifying the signer's identity through an OpenID Connect identity provider.
The certificate connects the signing operation to an authenticated identity.
Rekor
Rekor is Sigstore's transparency log. It records signing-related information so that verification can include evidence that a signing event was publicly recorded.
Together, these components help establish trust without requiring every developer to distribute and maintain long-lived signing keys manually.
Understanding How Container Image Signing Works
A typical Sigstore keyless signing workflow involves the build system, an OIDC identity provider, Fulcio, Rekor, Cosign, and a container registry.
The process works as follows:
A CI/CD pipeline builds a container image.
The pipeline pushes the image to a container registry.
The signing job obtains an OIDC identity token from its identity provider.
Cosign uses the token to request a short-lived certificate from Fulcio.
Cosign signs the image digest using an ephemeral private key.
The signature and related verification material are recorded through Sigstore infrastructure.
The signature is associated with the container image in the registry.
A deployment system retrieves the image and verifies its signature.
The deployment system checks whether the signing identity matches the organization's trust policy.
The important point is that the signature identifies the exact image content through its digest.
A tag such as latest or 1.0 is a mutable reference. The underlying image can change while the tag remains the same.
A digest identifies specific image content. For production signing and verification, prefer references such as:
registry.example.com/payment-api@sha256:IMAGE_DIGEST
This ensures that the signature verification applies to the exact image being deployed.
Installing Cosign
Before signing or verifying container images, install Cosign in your development environment or CI/CD runner.
The Sigstore project provides installation options for supported operating systems and package managers.
For example, on macOS, you can use Homebrew:
brew install cosign
After installation, verify the available version:
cosign version
For CI/CD environments, use the official Cosign installation instructions or a trusted installer action. Pin tool versions in automated pipelines rather than downloading an uncontrolled latest release during every build.
This improves build repeatability and makes security updates easier to review.
Building and Pushing a Container Image
For the following examples, assume that an application image is built using Docker and published to a container registry.
First, build the image:
docker build -t ghcr.io/mycompany/payment-api:1.0 .
Push the image:
docker push ghcr.io/mycompany/payment-api:1.0
After pushing, obtain the image digest from the registry or build process.
For example:
docker buildx imagetools inspect \
ghcr.io/mycompany/payment-api:1.0
The output includes the image digest.
Store the digest as part of the build metadata and use it for signing and later deployment.
The following examples use IMAGE_URI as a placeholder for the full image reference containing its digest.
Signing a Container Image With Cosign
Cosign supports keyless signing through an OIDC identity provider.
For example, when running in a supported CI/CD environment, the signing command can be:
cosign sign --yes "$IMAGE_URI"
The --yes option confirms the signing operation without requiring an interactive approval prompt.
During keyless signing, Cosign obtains an ephemeral signing key and requests a short-lived certificate through the configured OIDC identity provider.
The signing identity is associated with the certificate, and the signature is recorded using Sigstore's transparency infrastructure.
The signature is also associated with the image in the registry.
Keyless signing is useful in automated pipelines because developers do not need to store a long-lived private signing key as a CI/CD secret.
However, the CI/CD identity must be protected carefully. An attacker who gains control of an authorized build workflow may be able to produce images that satisfy the same identity policy.
Verifying a Signed Container Image
Signing an image is only useful when deployment systems verify it before execution.
Cosign provides the verify command for checking container image signatures.
For keyless verification, specify the expected certificate identity and OIDC issuer.
For example:
cosign verify "$IMAGE_URI" \
--certificate-identity="https://github.com/mycompany/payment-api/.github/workflows/release.yml@refs/heads/main" \
--certificate-oidc-issuer="https://token.actions.githubusercontent.com"
The certificate identity should match the actual identity used by the signing workflow.
For GitHub Actions, the identity can include the repository, workflow, and Git reference. The exact value depends on the workflow and identity format.
The OIDC issuer identifies the identity provider that issued the token.
Cosign checks the signature and validates the image claims, including the image digest. It also checks the certificate identity and issuer against the expected values.
If verification succeeds, Cosign returns the verified signature information.
If the signature is missing, invalid, or associated with an unexpected identity, verification fails.
Do not use unrestricted identity regular expressions in production simply to make verification easier. Define the expected signing identity as precisely as possible.
Using a Public and Private Key Pair
Keyless signing is convenient, but some organizations prefer managing their own signing keys.
Cosign supports traditional key-pair signing.
Generate a key pair:
cosign generate-key-pair
Cosign creates two files:
cosign.key
cosign.pub
The private key must be protected. It should not be committed to source control or included in a container image.
Sign the image:
cosign sign --key cosign.key "$IMAGE_URI"
Verify it using the public key:
cosign verify --key cosign.pub "$IMAGE_URI"
For production systems, consider storing signing keys in a supported cloud key management service or hardware-backed security system rather than keeping a private key as a regular file.
The verification system needs access to the corresponding trusted public key.
Key-based signing provides direct control over key ownership and rotation, but the organization becomes responsible for protecting, distributing, and maintaining those keys.
Integrating Cosign With GitHub Actions
A CI/CD pipeline is a practical place to sign container images because the build system already knows which source revision and workflow produced the artifact.
GitHub Actions supports OIDC tokens, allowing a workflow to authenticate with Sigstore without storing a long-lived signing key.
The workflow needs permission to request an OIDC token.
A simplified example is:
name: Build and Sign Container
on:
push:
branches:
- main
permissions:
contents: read
packages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
- name: Install Cosign
uses: sigstore/[email protected]
- name: Build and push image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/mycompany/payment-api:latest
- name: Sign image
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
IMAGE="ghcr.io/mycompany/payment-api@${DIGEST}"
cosign sign --yes "$IMAGE"
This example demonstrates the signing stage. It assumes that the workflow has the necessary container registry authentication and permissions configured.
The build action returns the image digest. The signing step uses that digest instead of signing only a mutable tag.
For a production pipeline, add a verification step that checks the expected certificate identity and OIDC issuer.
Pin third-party GitHub Actions to reviewed commit SHAs in security-sensitive workflows. Version tags are easier to read, but a reviewed immutable reference provides stronger supply chain control.
Adding Attestations to Container Images
A signature confirms that an image was signed by an identity. However, organizations often need additional information about how the image was produced.
This is where attestations become useful.
An attestation is structured metadata associated with an artifact. It can describe information such as build provenance, software bill of materials, or vulnerability scan results.
Cosign supports in-toto attestations.
For example, create a JSON predicate:
{
"buildType": "https://example.com/build-system",
"sourceRepository": "https://github.com/mycompany/payment-api",
"sourceRevision": "abc123",
"builder": "github-actions"
}
Save the file as provenance.json.
You can attach an attestation using:
cosign attest \
--yes \
--type custom \
--predicate provenance.json \
"$IMAGE_URI"
Attestations can be verified separately:
cosign verify-attestation \
"$IMAGE_URI" \
--type custom \
--certificate-identity="$EXPECTED_IDENTITY" \
--certificate-oidc-issuer="https://token.actions.githubusercontent.com"
The verification process checks the attestation signature and expected signer identity.
For production deployments, teams should also evaluate the attestation predicate itself. A valid signature does not automatically mean that every statement inside the attestation satisfies organizational policy.
Enforcing Signature Verification Before Deployment
Signing images in CI/CD is only one part of the security process.
A deployment system must reject images that do not meet the organization's trust requirements.
A practical policy might require:
The image must have a valid Cosign signature.
The signing certificate must belong to an approved repository.
The certificate issuer must be the expected OIDC provider.
The image must be referenced by digest.
Required provenance attestations must be present.
The source revision must come from an approved branch or release process.
Kubernetes environments can enforce image verification through admission control systems and policy engines.
For example, an admission policy can prevent workloads from being created when their images do not satisfy the organization's signature requirements.
The exact implementation depends on the Kubernetes platform and policy controller being used.
It is important to enforce verification before workloads start. A manual verification command run by a developer is useful for troubleshooting, but it does not guarantee that every deployment follows the same process.
Common Mistakes to Avoid
Signing Mutable Image Tags
A tag can point to different image content over time.
Use image digests for signing, verification, and deployment references. This ensures that the verification process is connected to the exact artifact.
Accepting Any Valid Signature
A valid signature does not necessarily mean that the image came from an approved source.
Always verify the expected certificate identity and OIDC issuer. Trust should be based on an explicit policy rather than the presence of any signature.
Storing Private Keys in Source Control
Committing a Cosign private key to a repository exposes it to unauthorized users.
Use keyless signing or a supported key management service. Restrict access to signing credentials and rotate keys when required.
Skipping Verification During Deployment
An image can be signed correctly and still be deployed incorrectly if the deployment pipeline never checks its signature.
Make verification a required deployment step or enforce it through admission control.
Treating Signatures as Vulnerability Scans
A valid signature proves that the signed content matches the signed artifact and satisfies the selected identity checks.
It does not prove that the image contains no vulnerabilities, malware, or insecure dependencies.
Combine image signing with vulnerability scanning, dependency analysis, and build provenance verification.
Using Overly Broad Identity Rules
Accepting any identity from a trusted OIDC provider may allow unauthorized workflows to produce deployable images.
Use precise certificate identity and issuer requirements. Review those requirements whenever repository names, workflow paths, or release processes change.
Best Practices for Production Environments
Build and sign images in controlled CI/CD pipelines. Restrict who can modify the workflows that receive signing permissions.
Use immutable image digests throughout the build, signing, verification, and deployment process.
Prefer keyless signing when it fits the organization's identity infrastructure and trust requirements. If using private keys, protect them with appropriate key management controls.
Verify both the signature and the expected signer identity. Do not treat a successful cryptographic check as sufficient without checking who signed the artifact.
Use attestations to provide additional evidence about the build process. Define clear policies for which provenance information is required before deployment.
Integrate verification into the deployment path, preferably through automated policy enforcement.
Finally, monitor signing and verification failures. These events can reveal configuration problems, expired trust material, unauthorized image publishing, or attempts to deploy unapproved artifacts.
Conclusion
Container image signing is an important part of securing the software supply chain. It helps organizations establish trust in container images before they are deployed to production environments.
Sigstore and Cosign make this process easier through keyless signing, cryptographic verification, transparency logging, and support for software attestations.
A reliable implementation should sign images using their immutable digests, verify the expected signing identity, protect signing permissions, and enforce verification before deployment.
When combined with vulnerability scanning, provenance checks, and secure CI/CD practices, Cosign helps teams build a more trustworthy container delivery process.
Join the conversation! Your thoughts help the community grow.