<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
---
name: implementing-container-image-provenance
description: >-
  Implement container image provenance verification using cosign signatures,
  SBOM attestations, Sigstore transparency logs, and admission controllers
  to enforce signed image policies in Kubernetes clusters.
domain: cybersecurity
subdomain: cloud-native-security
tags:
  - cosign
  - sigstore
  - sbom
  - image-signing
  - supply-chain
  - admission-controller
  - provenance
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1195.002"]
---

# Implementing Container Image Provenance

## Overview

Implement container image provenance verification using cosign signatures, SBOM attestations, Sigstore transparency logs, and admission controllers to enforce signed image policies in Kubernetes clusters.

Mode: `[MODE: ARCHITECT]` — Design signing pipeline. `[MODE: BLUE]` — Enforce signed images.

## Prerequisites

| Requirement | Details |
|---|---|
| cosign >= 2.2 installed | Required |
| Container registry with OCI support | Required |
| Kyverno >= 1.11 or OPA Gatekeeper deployed | Required |

## Key Concepts

### Sign Container Images

```bash
# Generate cosign key pair
cosign generate-key-pair

# Sign image
cosign sign --key cosign.key registry.example.com/app:v1.0

# Keyless signing with Sigstore (OIDC)
cosign sign registry.example.com/app:v1.0

# Verify signature
cosign verify --key cosign.pub registry.example.com/app:v1.0
```

### Generate and Attach SBOM

```bash
# Generate SBOM with syft
syft registry.example.com/app:v1.0 -o spdx-json > sbom.json

# Attach SBOM as attestation
cosign attest --predicate sbom.json \
  --type spdxjson --key cosign.key \
  registry.example.com/app:v1.0

# Verify attestation
cosign verify-attestation --key cosign.pub \
  --type spdxjson registry.example.com/app:v1.0
```

### Kyverno Image Verification Policy

```yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-image-signature
spec:
  validationFailureAction: Enforce
  rules:
  - name: verify-cosign
    match:
      any:
      - resources:
          kinds: ["Pod"]
    verifyImages:
    - imageReferences: ["registry.example.com/*"]
      attestors:
      - count: 1
        entries:
        - keys:
            publicKeys: |-
              -----BEGIN PUBLIC KEY-----
              <cosign-public-key>
              -----END PUBLIC KEY-----
```

### Audit Unsigned Images

```bash
# List images in cluster without signatures
kubectl get pods -A -o json | \
  jq -r '.items[].spec.containers[].image' | sort -u | \
  while read img; do
    cosign verify --key cosign.pub "$img" 2>/dev/null || echo "UNSIGNED: $img"
  done
```

## Workflow

```bash
node scripts/agent.js --action audit --namespace production
cat /tmp/implementing-container-image-provenance-audit.json | jq '.findings[]'
```

## Detection

```yaml
title: Container Image Provenance Detection
id: 544f3461-f7e2-44da-b82d-d8c31d20792d
status: experimental
description: Detects suspicious activity related to implementing container image provenance techniques in cloud native security context
logsource:
  product: kubernetes
  service: audit
detection:
  selection:
    eventName: "*Unauthorized*"
  condition: selection
level: medium
tags:
  - attack.t1195.002
  - attack.privilege_escalation
falsepositives:
  - Kubernetes controller reconciliation loops during cluster updates
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Container Image Provenance Detection | kubernetes | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1195.002 |

## Verification

- [ ] All production images signed with cosign
- [ ] SBOM attestations attached to release images
- [ ] Kyverno/Gatekeeper enforcing signature verification
- [ ] CI/CD pipeline signs images before push
- [ ] Admission webhook rejects unsigned images

## References

- [Sigstore Cosign Documentation](https://docs.sigstore.dev/cosign/overview/)
- [Kyverno Image Verification](https://kyverno.io/docs/writing-policies/verify-images/)
- [SLSA Supply Chain Framework](https://slsa.dev/)
- [NIST SP 800-190 — Container Security](https://csrc.nist.gov/publications/detail/sp/800-190/final)
