<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
---
name: implementing-image-signing-verification
description: >-
  Implement container image signing and verification workflows using Cosign,
  Notation, and Sigstore to ensure image integrity and provenance across CI/CD
  pipelines and Kubernetes admission control.
domain: cybersecurity
subdomain: container-security
tags:
  - cosign
  - sigstore
  - notation
  - image-signing
  - supply-chain
  - admission-control
  - provenance
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1195.002"]
---

# Implementing Image Signing & Verification

## Overview

Image signing establishes a cryptographic chain of trust from build to deploy.
This skill covers key-based and keyless signing with Cosign, SBOM and SLSA
provenance attestations, Notation for ORAS-based signing, and Kubernetes
admission policies that reject unsigned or unverified images.

Mode: `[MODE: BLUE]` — Defensive supply chain integrity.

## Prerequisites

| Requirement | Details |
|---|---|
| Cosign >= 2.2 installed | Required |
| Notation >= 1.0 for ORAS-based signing | Required |
| Kubernetes >= 1.25 with admission controller | Required |
| Sigstore Rekor for transparency log | Required |
| Container registry with OCI artifact support | Required |

## Key Concepts

### Cosign Key-Based Signing

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

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

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

# Sign with annotations
cosign sign --key cosign.key \
  -a "build-id=ci-1234" \
  -a "git-sha=$(git rev-parse HEAD)" \
  registry.example.com/app:v1.0
```

### Keyless Signing with Sigstore

```bash
# Keyless sign (uses OIDC identity)
cosign sign registry.example.com/app:v1.0

# Verify keyless signature
cosign verify \
  --certificate-identity user@example.com \
  --certificate-oidc-issuer https://accounts.google.com \
  registry.example.com/app:v1.0

# Verify GitHub Actions identity
cosign verify \
  --certificate-identity "https://github.com/org/repo/.github/workflows/build.yml@refs/heads/main" \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  registry.example.com/app:v1.0
```

### Attach SBOM and Attestations

```bash
# Attach SBOM to image
cosign attach sbom --sbom sbom.spdx.json registry.example.com/app:v1.0

# Create and attach attestation
cosign attest --predicate provenance.json \
  --key cosign.key registry.example.com/app:v1.0

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

### Kubernetes Admission Enforcement

```yaml
apiVersion: policy.sigstore.dev/v1alpha1
kind: ClusterImagePolicy
metadata:
  name: require-signing
spec:
  images:
    - glob: "registry.example.com/**"
  authorities:
    - keyless:
        url: https://fulcio.sigstore.dev
        identities:
          - issuer: https://token.actions.githubusercontent.com
            subject: "https://github.com/org/repo/*"
```

## Workflow

### Step 1: Generate Signing Keys

```bash
cosign generate-key-pair --output-key-prefix ci-signing
```

### Step 2: Sign and Verify Image

```bash
node scripts/agent.js --sign --image registry.example.com/app:v1.0 \
  --key cosign.key --output /tmp/sign-report.json
```

### Step 3: Verify Deployment Images

```bash
node scripts/agent.js --verify --namespace production --output /tmp/verify-report.json
```

## Detection

```yaml
title: Image Signing Verification Detection
id: 55a0e92f-09a0-442b-a2db-24f84d81bb26
status: experimental
description: Detects suspicious activity related to implementing image signing verification techniques in container security context
logsource:
  product: kubernetes
  service: audit
detection:
  selection:
    eventName: "*Unauthorized*"
  condition: selection
level: medium
tags:
  - attack.t1195.002
  - attack.execution
falsepositives:
  - Container orchestration platform performing routine health checks
```


**Detection Opportunities**

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

## Verification

- [ ] All production images signed before push to registry
- [ ] Cosign verification passes for all deployed images
- [ ] SBOM attestations attached to release images
- [ ] Kubernetes admission controller rejects unsigned images
- [ ] CI/CD pipeline includes signing step after build
- [ ] Transparency log entries exist in Rekor for all signatures

## References

- [Cosign Documentation — Sigstore](https://docs.sigstore.dev/cosign/overview/)
- [Notation — ORAS Signing](https://notaryproject.dev/)
- [SLSA Framework — Supply Chain Levels](https://slsa.dev/)
- [Kubernetes Image Policy Admission](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/)
- [NIST SP 800-190 §4.1.4 — Image Integrity](https://csrc.nist.gov/publications/detail/sp/800-190/final)
