What a Signature Proves
A digital signature binds three things: some bytes, a private key, and (through the matching public key) an identity. Verifying it proves that the holder of the private key signed exactly these bytes. It proves nothing else, and most supply-chain mistakes with signatures come from assuming it does. The mechanics (hashes, key pairs, ECDSA, Ed25519) are in Digital Signatures; this lesson is about what they mean for artifacts.
A model: sign, verify, tamper
Ed25519 signatures are deterministic: the same key and message always give the same signature, which makes them nice for a reproducible example. The model signs a release's digest, then verifies three things a consumer might receive.
import hashlib
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.exceptions import InvalidSignature
# Fixed keys for the example; real keys come from a secure generator or a KMS.
release_key = Ed25519PrivateKey.from_private_bytes(bytes(range(32)))
other_key = Ed25519PrivateKey.from_private_bytes(bytes(range(1, 33)))
trusted_pub = release_key.public_key()
artifact = b"app 1.4.2 binary bytes"
digest = hashlib.sha256(artifact).hexdigest()
payload = f'{{"artifact":"app","version":"1.4.2","sha256":"{digest}"}}'.encode()
signature = release_key.sign(payload)
print("digest: ", digest[:16], "...")
print("signature:", signature.hex()[:32], "...", len(signature), "bytes")
def verify(label, payload, signature, received_artifact):
try:
trusted_pub.verify(signature, payload)
except InvalidSignature:
print(f"{label:28} REJECTED: signature invalid")
return
claimed = payload.split(b'"sha256":"')[1][:64].decode()
actual = hashlib.sha256(received_artifact).hexdigest()
print(f"{label:28} {'OK' if claimed == actual else 'REJECTED: artifact does not match signed digest'}")
verify("original", payload, signature, artifact)
verify("tampered artifact", payload, signature, artifact + b"!")
verify("tampered payload", payload.replace(b"1.4.2", b"1.4.3"), signature, artifact)
verify("signed by another key", payload, other_key.sign(payload), artifact)digest: 87a18d6d6d2ee411 ...
signature: e54843389073b576c98dcacab73c9ee1 ... 64 bytes
original OK
tampered artifact REJECTED: artifact does not match signed digest
tampered payload REJECTED: signature invalid
signed by another key REJECTED: signature invalid
Note the structure, because cosign does the same: the signature covers a small payload that contains the artifact's digest, not the artifact itself. Verifying is two steps: check the signature over the payload with a trusted key, then check that the payload's digest matches the artifact you actually have. Skipping the second step is a real bug class.
The same with openssl
With an ECDSA P-256 key (the default curve of cosign key pairs), signatures are randomized, so the bytes differ on every run, but verification behaves the same:
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out release.key 2> /dev/null
openssl pkey -in release.key -pubout -out release.pub
printf 'app 1.4.2 binary bytes' > app.bin
openssl dgst -sha256 -sign release.key -out app.bin.sig app.bin
openssl dgst -sha256 -verify release.pub -signature app.bin.sig app.bin
printf '!' >> app.bin
openssl dgst -sha256 -verify release.pub -signature app.bin.sig app.binVerified OK
Verification failure
What a valid signature does not prove
| Assumption | Reality |
|---|---|
| "It's signed, so it's safe" | It's signed by someone who had the key. SolarWinds and 3CX shipped validly signed malware. |
| "It's signed, so it's ours" | Only if you checked the key or identity. A signature by any key verifies against that key. Verifying against a key fetched from the same place as the artifact proves nothing. |
| "It's signed, so it's the latest" | A signature doesn't expire by itself. An old, vulnerable, validly signed release is still validly signed (rollback / freeze attacks). |
| "The key is fine" | A leaked key signs for the attacker. Without a way to know when a signature was made (a transparency log, a timestamp), you can't tell old signatures from forged new ones after a revocation. |
These gaps drive the rest of the section: key management and short-lived keys (Keyless Signing), policies that say which identity must have signed (Checking Attestations with Policies), and signed statements about how an artifact was built (Provenance).
Signing artifacts in practice
| Ecosystem | Signing today |
|---|---|
| Container images | cosign / Sigstore (signatures stored in the registry), Notary v2 / Notation |
| Release files | cosign sign-blob bundles, GPG detached signatures (.asc), minisign |
| npm | registry signatures on every package, plus provenance attestations (npm publish --provenance) via Sigstore |
| PyPI | PEP 740 attestations through Trusted Publishing, using Sigstore (Trusted Publishing) |
| Maven Central | GPG signatures required on every artifact; Sigstore bundles can be published alongside them |
| Git | signed commits and tags (GPG, SSH or Sigstore's gitsign) |
The common direction is away from long-lived personal keys toward identities bound to CI workflows, which is what Sigstore was built for.
Test yourself
A cosign-style signature covers a payload containing the image digest. What must a verifier check besides the signature?
- Nothing else
- That the digest in the payload matches the artifact it actually has
- That the tag is latest
- That the payload is small
Why is verifying a signature against a public key downloaded from the same server as the artifact weak?
- Public keys can't be downloaded
- An attacker who controls the server can replace both the artifact and the key
- It is slower
- ECDSA keys expire
Why do two ECDSA signatures of the same file with the same key usually differ?
- The key changes
- ECDSA uses a fresh random nonce for each signature
- openssl adds a timestamp
- The file changes