<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
---
name: implementing-artifact-signing
description: >-
  Implement cryptographic artifact signing using Sigstore cosign, GPG, and
  Notation for container images, binaries, and release artifacts. Configure
  keyless signing with OIDC, key management, and signature verification policies.
domain: cybersecurity
subdomain: supply-chain-security
tags:
  - code-signing
  - cosign
  - sigstore
  - gpg
  - notation
  - artifact-verification
  - container-signing
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1553.002"]
---

# Implementing Artifact Signing

## Overview

Artifact signing provides cryptographic proof of origin and integrity — ensuring
consumers can verify that artifacts were produced by trusted builders and have
not been tampered with. This skill covers signing container images with cosign
(keyless and key-based), GPG signing for binaries, Notation for OCI artifacts,
and implementing verification policies in admission controllers.

Mode: `[MODE: ARCHITECT]` — Design signing infrastructure; `[MODE: BLUE]` — Verify artifact signatures.

## Prerequisites

| Requirement | Details |
|---|---|
| cosign (`brew install cosign`) | Required |
| GPG for binary signing | Required |
| Notation CLI (`brew install notation`) | Required |
| Kyverno or OPA Gatekeeper for admission control | Required |
| OIDC provider for keyless signing (GitHub, Google, Microsoft) | Required |

## Key Concepts

### Cosign Key-Based Signing

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

# Sign container image
cosign sign --key cosign.key ghcr.io/org/app:v1.2.3

# Verify signature
cosign verify --key cosign.pub ghcr.io/org/app:v1.2.3

# Sign with annotations
cosign sign --key cosign.key \
  -a "commit=$(git rev-parse HEAD)" \
  -a "pipeline=github-actions" \
  ghcr.io/org/app:v1.2.3
```

### Cosign Keyless Signing (Sigstore)

```bash
# Keyless sign (uses OIDC identity — Fulcio CA + Rekor transparency log)
cosign sign ghcr.io/org/app:v1.2.3 --yes

# Verify keyless signature
cosign verify ghcr.io/org/app:v1.2.3 \
  --certificate-identity "https://github.com/org/repo/.github/workflows/release.yml@refs/tags/v1.2.3" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com"

# Verify with certificate identity regex
cosign verify ghcr.io/org/app:v1.2.3 \
  --certificate-identity-regexp ".*@refs/tags/v.*" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com"
```

### GPG Binary Signing

```bash
# Generate GPG key
gpg --full-generate-key

# Sign binary
gpg --armor --detach-sign --output app.sig app

# Verify signature
gpg --verify app.sig app

# Sign with specific key
gpg --armor --detach-sign --local-user security@company.com app.tar.gz
```

### Admission Control Verification

```yaml
# Kyverno policy — require signed images
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-image-signatures
spec:
  validationFailureAction: Enforce
  rules:
    - name: verify-cosign-signature
      match:
        any:
          - resources:
              kinds: ["Pod"]
      verifyImages:
        - imageReferences: ["ghcr.io/org/*"]
          attestors:
            - entries:
                - keyless:
                    issuer: "https://token.actions.githubusercontent.com"
                    subject: "https://github.com/org/*"
```

## Workflow

### Step 1: Sign Artifact

```bash
node scripts/agent.js --action sign --artifact ghcr.io/org/app:v1.2.3 --method keyless --output /tmp/sign-result.json
```

### Step 2: Verify Signature

```bash
node scripts/agent.js --action verify --artifact ghcr.io/org/app:v1.2.3 --key cosign.pub --output /tmp/verify-result.json
```

### Step 3: Audit Signing Policy

```bash
node scripts/agent.js --action audit --namespace default --output /tmp/signing-audit.json
```

## Detection

```yaml
title: Artifact Signing Detection
id: ef507164-c849-47d6-a0b1-10b4bf3c3b1a
status: experimental
description: Detects suspicious activity related to implementing artifact signing techniques in supply chain security context
logsource:
  category: process_creation
  product: linux
detection:
  selection:
    CommandLine: "*implementing*artifact*"
  condition: selection
level: medium
tags:
  - attack.t1553.002
  - attack.initial_access
falsepositives:
  - Package manager performing routine dependency resolution
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Artifact Signing Detection | linux/process_creation | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1553.002 |

## Verification

- [ ] All container images signed before deployment
- [ ] Keyless signing configured with OIDC identity binding
- [ ] Admission controller enforces signature verification
- [ ] Signing keys rotated on schedule (key-based) or ephemeral (keyless)
- [ ] Transparency log entries verified (Rekor)
- [ ] Binary releases include detached GPG signatures

## References

- [Sigstore Documentation](https://docs.sigstore.dev/)
- [Cosign Documentation](https://docs.sigstore.dev/cosign/signing/signing_with_containers/)
- [Kyverno Image Verification](https://kyverno.io/docs/writing-policies/verify-images/)
- [Notation Project](https://notaryproject.dev/)
