Back to Security Guide

Supply Chain Security

Image Signing, SBOM, Artifact Verification, and CI/CD Pipeline Hardening

Supply Chain Security Overview

Container supply chain security ensures that the code and dependencies in your container images are verified and trustworthy. It covers vulnerability scanning, image signing, SBOM generation, CI/CD pipeline security, and artifact verification.

💡 Key Insight: A container is only as secure as its weakest dependency. Supply chain attacks are increasingly targeting container ecosystems.

Vulnerability Scanning

Container Image Scanning Tools

Tool Features
Trivy Fast, comprehensive vulnerability scanning for images, config, code
Grype SBOM-based vulnerability detection
Aqua Microscanner Container image scanning in build pipelines
Snyk Developer-focused vulnerability scanning and remediation
Anchore Policy-based image scanning and compliance

Scan with Trivy

# Scan image for vulnerabilities trivy image myregistry.azurecr.io/myapp:latest # Scan with output format trivy image --format json myapp:latest # Scan source code trivy fs .

Scanning in CI/CD

Image Signing with Cosign

Cosign Overview

Cosign enables container image signing and verification using cryptographic signatures:

Sign an Image

# Generate keys (one-time) cosign generate-key-pair # Sign image cosign sign --key cosign.key myregistry.azurecr.io/myapp:latest # Verify signature cosign verify --key cosign.pub myregistry.azurecr.io/myapp:latest

Enforce Signature Verification

Use admission controllers to require signed images:

SBOM (Software Bill of Materials)

What is SBOM?

A complete inventory of all software components and dependencies in an image:

Generate SBOM

# Generate with Syft syft myregistry.azurecr.io/myapp:latest -o json > sbom.json # Generate with Trivy trivy image --format sbom --output sbom.spdx myapp:latest # Sign SBOM with Cosign cosign attach sbom --sbom sbom.spdx myregistry.azurecr.io/myapp:latest

SBOM Benefits

⚠️ Important: SBOM helps track vulnerabilities but doesn't prevent attacks. Combine with other controls like image signing and vulnerability scanning.

CI/CD Pipeline Hardening

Secure Build Pipeline

Example GitHub Actions Workflow

name: Secure Build on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Run Trivy scan uses: aquasecurity/trivy-action@master with: image-ref: myapp:${{ github.sha }} - name: Sign image with Cosign run: cosign sign --key ${{ secrets.COSIGN_KEY }} myregistry.azurecr.io/myapp:latest

Pipeline Best Practices

Supply Chain Security Checklist

Recommended Tools Stack