# cosign attest: Attach an SBOM Attestation

> cosign attest attaches a signed SBOM or provenance attestation to an image. Reference for --predicate, --type, verify-attestation, and CI errors.

Source: https://latchkey.dev/learn/command-reference/cosign-attest-sbom  
Updated: 2026-06-30

cosign attest signs an attestation (such as an SBOM or build provenance) and attaches it to a container image.

A signature says who built an image; an attestation says what is inside it or how it was made. cosign attest binds a signed predicate, often an SBOM, to the image digest.

## What it does

cosign attest wraps a predicate file (an SBOM, SLSA provenance, or custom JSON) in an in-toto attestation, signs it (key-based or keyless), and stores it next to the image. cosign verify-attestation later checks the signature and the predicate type, optionally evaluating a policy against the predicate.

## Common usage

```Terminal
# attach a CycloneDX SBOM attestation, keyless
syft ghcr.io/org/app@${DIGEST} -o cyclonedx-json=sbom.cdx.json
cosign attest --yes --type cyclonedx \
  --predicate sbom.cdx.json ghcr.io/org/app@${DIGEST}
# verify the attestation by identity
cosign verify-attestation --type cyclonedx \
  --certificate-identity-regexp 'https://github.com/org/.+' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  ghcr.io/org/app@${DIGEST}
```

## Options

| Flag | What it does |
| --- | --- |
| --predicate <file> | The predicate JSON (SBOM, provenance, custom) |
| --type <type> | Predicate type: cyclonedx, spdxjson, slsaprovenance, custom |
| --key <ref> | Signing key (omit for keyless) |
| --yes | Skip the confirmation prompt |
| --policy <file> | CUE/Rego policy for verify-attestation |

## In CI

Generate the SBOM with syft or trivy, then cosign attest --type cyclonedx (or spdxjson) keylessly so the SBOM is signed and stored with the image. Verify it in the deploy gate with cosign verify-attestation, pinning the same identity and issuer used at build time.

## Common errors in CI

"invalid predicate type" means --type does not match the predicate format; use cyclonedx for CycloneDX and spdxjson for SPDX. "no matching attestations" on verify means the type filter differs from what was attached, or you verified a moved tag. EOF on the password prompt means COSIGN_PASSWORD is unset for a key-based attest.

## FAQ

### cosign attest: Attach an SBOM Attestation?

A signature says who built an image; an attestation says what is inside it or how it was made. cosign attest binds a signed predicate, often an SBOM, to the image digest.

### What it does?

cosign attest wraps a predicate file (an SBOM, SLSA provenance, or custom JSON) in an in-toto attestation, signs it (key-based or keyless), and stores it next to the image. cosign verify-attestation later checks the signature and the predicate type, optionally evaluating a policy against the predicate.

### In CI?

Generate the SBOM with syft or trivy, then cosign attest --type cyclonedx (or spdxjson) keylessly so the SBOM is signed and stored with the image. Verify it in the deploy gate with cosign verify-attestation, pinning the same identity and issuer used at build time.

### Common errors in CI?

"invalid predicate type" means --type does not match the predicate format; use cyclonedx for CycloneDX and spdxjson for SPDX. "no matching attestations" on verify means the type filter differs from what was attached, or you verified a moved tag. EOF on the password prompt means COSIGN_PASSWORD is unset for a key-based attest.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
