{"id":"GHSA-2x42-5f92-cm4x","aliases":["DHI-5sjj-nyr6-c2dc-4rms"],"status":"published","description":"# Unverified Target Manifest \u0026 Bundle Blob Digests in Local OCI Bundle Verification (`GetLocalBundles`) in `cosign`\r\n\r\n- **Target Repository:** `sigstore/cosign` (verified at `HEAD` `ef56e6999cdad185e5e155cccf1223951abfc77a`)\r\n\r\n---\r\n\r\n### Summary\r\n\r\nIn `VerifyLocalImageSignatures` (`pkg/cosign/verify.go:718-741`) and legacy `VerifyLocalImageAttestations` (`pkg/cosign/verify.go:1137-1160`), Cosign loads the target image/index from the local OCI layout via `se.SignedImage(v1.Hash{})` / `se.SignedImageIndex(v1.Hash{})` and computes its SHA-256 digest (`i.Digest()` / `ii.Digest()`) from the manifest blob on disk before verifying signatures or attestations against that computed digest.\r\n\r\nIn contrast, when `NewBundleFormat: true` is used (`verifyLocalImageAttestationsSigstoreBundle` -\u003e `GetLocalBundles` -\u003e `getLocalBundleDescriptors`, `pkg/cosign/verify.go:1820-1942`), `getLocalBundleDescriptors` reads `targetDigest = m.Digest` directly from `index.json` without reading or hashing `blobs/sha256/\u003ctargetDigest.Hex\u003e`, and `GetLocalBundles` reads `descriptor.blobPath` without verifying its SHA-256 digest against `descriptor.digest`.\r\n\r\nIf an attacker modifies the target image manifest blob `blobs/sha256/\u003ctargetDigest.Hex\u003e` in a local OCI layout (e.g., pointing it to a tampered layer) while leaving `m.Digest` unchanged in `index.json`, `GetLocalBundles` and `VerifyLocalImageAttestations` (`cosign verify-attestation --new-bundle-format --local-image \u003cPATH\u003e`) succeed and report the tampered local image as verified.\r\n\r\n---\r\n\r\n### Minimal Reproduction \u0026 Verbatim Test Output\r\n\r\n```text\r\n$ go test -v ./pkg/cosign -run 'TestGetLocalBundles_TamperedTargetManifestBlob'\r\n=== RUN   TestGetLocalBundles_TamperedTargetManifestBlob\r\n--- PASS: TestGetLocalBundles_TamperedTargetManifestBlob (0.00s)\r\nPASS\r\nok  \tgithub.com/sigstore/cosign/v3/pkg/cosign\t0.012s\r\n```\r\n\r\n---\r\n\r\n### Proposed Patch (`fix.patch`)\r\n\r\n```diff\r\ndiff --git a/pkg/cosign/verify.go b/pkg/cosign/verify.go\r\nindex 6edf6ee..a4b9011 100644\r\n--- a/pkg/cosign/verify.go\r\n+++ b/pkg/cosign/verify.go\r\n@@ -1823,6 +1823,21 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu\r\n \t\treturn nil, nil, err\r\n \t}\r\n \r\n+\tif hash != nil \u0026\u0026 len(descriptors) \u003e 0 {\r\n+\t\ttargetBlobPath := filepath.Clean(filepath.Join(path, \"blobs\", hash.Algorithm, hash.Hex))\r\n+\t\ttargetBytes, err := os.ReadFile(targetBlobPath)\r\n+\t\tif err != nil {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"reading target manifest blob %s: %w\", hash.Hex, err)\r\n+\t\t}\r\n+\t\tactualTargetHash, _, err := v1.SHA256(bytes.NewReader(targetBytes))\r\n+\t\tif err != nil {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"hashing target manifest blob %s: %w\", hash.Hex, err)\r\n+\t\t}\r\n+\t\tif actualTargetHash != *hash {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"target manifest digest mismatch: index.json declares %s, but blob hashes to %s\", *hash, actualTargetHash)\r\n+\t\t}\r\n+\t}\r\n+\r\n \tbundles := make([]*sgbundle.Bundle, 0, len(descriptors))\r\n \tfor _, descriptor := range descriptors {\r\n \t\tbundleBytes, err := os.ReadFile(filepath.Join(path, descriptor.blobPath))\r\n@@ -1831,6 +1846,12 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu\r\n \t\t\tcontinue\r\n \t\t}\r\n \r\n+\t\tactualBundleHash, _, err := v1.SHA256(bytes.NewReader(bundleBytes))\r\n+\t\tif err != nil || actualBundleHash != descriptor.digest {\r\n+\t\t\tui.Warnf(context.Background(), \"Bundle blob %s digest mismatch: got %s\", descriptor.digest.Hex, actualBundleHash.Hex)\r\n+\t\t\tcontinue\r\n+\t\t}\r\n+\r\n \t\tpb := \u0026protobundle.Bundle{}\r\n \t\tif err := protojson.Unmarshal(bundleBytes, pb); err != nil {\r\n \t\t\tui.Warnf(context.Background(), \"Failed to unmarshal bundle %s: %v\", descriptor.digest.Hex, err)\r\ndiff --git a/pkg/cosign/verify_test.go b/pkg/cosign/verify_test.go\r\nindex b7ac541..55e182d 100644\r\n--- a/pkg/cosign/verify_test.go\r\n+++ b/pkg/cosign/verify_test.go\r\n@@ -2896,3 +2896,32 @@ func TestVerifyImageSignatureWithBundleBodyMissingHash(t *testing.T) {\r\n \t\t})\r\n \t}\r\n }\r\n+\r\n+func TestGetLocalBundles_TamperedTargetManifestBlob(t *testing.T) {\r\n+\ttmp := createV3BundleLayout(t)\r\n+\r\n+\tp, err := ggcrlayout.FromPath(tmp)\r\n+\trequire.NoError(t, err)\r\n+\tii, err := p.ImageIndex()\r\n+\trequire.NoError(t, err)\r\n+\tidxManifest, err := ii.IndexManifest()\r\n+\trequire.NoError(t, err)\r\n+\r\n+\tvar targetDigest v1.Hash\r\n+\tfor _, m := range idxManifest.Manifests {\r\n+\t\tif m.Annotations[\"kind\"] == \"dev.cosignproject.cosign/image\" {\r\n+\t\t\ttargetDigest = m.Digest\r\n+\t\t\tbreak\r\n+\t\t}\r\n+\t}\r\n+\trequire.NotEmpty(t, targetDigest.Hex)\r\n+\r\n+\t// Tamper with the target image manifest blob on disk without updating index.json\r\n+\ttargetBlobPath := filepath.Join(tmp, \"blobs\", \"sha256\", targetDigest.Hex)\r\n+\terr = os.WriteFile(targetBlobPath, []byte(`{\"schemaVersion\":2,\"mediaType\":\"application/vnd.oci.image.manifest.v1+json\",\"Tampered\":true}`), 0644)\r\n+\trequire.NoError(t, err)\r\n+\r\n+\t_, _, err = GetLocalBundles(tmp)\r\n+\trequire.Error(t, err)\r\n+\tassert.Contains(t, err.Error(), \"target manifest digest mismatch\")\r\n+}\r\n```","facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":false},"published":"2026-12-04T14:13:52Z","modified":"2026-12-04T14:30:11Z","affected":[{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-2-dev","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.6.2-r0"}]}],"versions":["2.6.2-r0","2.6.2-r1","2.6.2-r2","2.6.2-r3","2.6.3-r0","2.6.3-r1","2.6.3-r10","2.6.3-r2","2.6.3-r3","2.6.3-r4","2.6.3-r5","2.6.3-r6","2.6.3-r7","2.6.3-r8","2.6.3-r9","2.6.4-r0","2.6.4-r1","2.6.5-r0","2.6.5-r1","2.6.5-r10","2.6.5-r11","2.6.5-r12","2.6.5-r13","2.6.5-r14","2.6.5-r2","2.6.5-r3","2.6.5-r4","2.6.5-r5","2.6.5-r6","2.6.5-r7","2.6.5-r8","2.6.5-r9"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-2-fips-dev","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.6.2-r0"}]}],"versions":["2.6.2-r0","2.6.2-r1","2.6.2-r2","2.6.2-r3","2.6.3-r0","2.6.3-r1","2.6.3-r10","2.6.3-r2","2.6.3-r3","2.6.3-r4","2.6.3-r5","2.6.3-r6","2.6.3-r7","2.6.3-r8","2.6.3-r9","2.6.4-r0","2.6.4-r1","2.6.5-r0","2.6.5-r1","2.6.5-r10","2.6.5-r11","2.6.5-r12","2.6.5-r13","2.6.5-r14","2.6.5-r2","2.6.5-r3","2.6.5-r4","2.6.5-r5","2.6.5-r6","2.6.5-r7","2.6.5-r8","2.6.5-r9"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-2-fips","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.6.2-r0"}]}],"versions":["2.6.2-r0","2.6.2-r1","2.6.2-r2","2.6.2-r3","2.6.3-r0","2.6.3-r1","2.6.3-r10","2.6.3-r2","2.6.3-r3","2.6.3-r4","2.6.3-r5","2.6.3-r6","2.6.3-r7","2.6.3-r8","2.6.3-r9","2.6.4-r0","2.6.4-r1","2.6.5-r0","2.6.5-r1","2.6.5-r10","2.6.5-r11","2.6.5-r12","2.6.5-r13","2.6.5-r14","2.6.5-r2","2.6.5-r3","2.6.5-r4","2.6.5-r5","2.6.5-r6","2.6.5-r7","2.6.5-r8","2.6.5-r9"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-2","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.6.2-r0"}]}],"versions":["2.6.2-r0","2.6.2-r1","2.6.2-r2","2.6.2-r3","2.6.3-r0","2.6.3-r1","2.6.3-r10","2.6.3-r2","2.6.3-r3","2.6.3-r4","2.6.3-r5","2.6.3-r6","2.6.3-r7","2.6.3-r8","2.6.3-r9","2.6.4-r0","2.6.4-r1","2.6.5-r0","2.6.5-r1","2.6.5-r10","2.6.5-r11","2.6.5-r12","2.6.5-r13","2.6.5-r14","2.6.5-r2","2.6.5-r3","2.6.5-r4","2.6.5-r5","2.6.5-r6","2.6.5-r7","2.6.5-r8","2.6.5-r9"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-3-dev","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.4-r0"}]}],"versions":["3.0.4-r0","3.0.5-r0","3.0.5-r1","3.0.5-r2","3.0.5-r3","3.0.6-r0","3.0.6-r1","3.0.6-r2","3.0.6-r3","3.0.6-r4","3.0.6-r5","3.0.6-r6","3.1.1-r0","3.1.1-r1","3.1.1-r2","3.1.2-r0","3.1.2-r1","3.1.3-r0","3.1.3-r1","3.1.3-r10","3.1.3-r11","3.1.3-r12","3.1.3-r13","3.1.3-r2","3.1.3-r3","3.1.3-r4","3.1.3-r5","3.1.3-r6","3.1.3-r7","3.1.3-r8","3.1.3-r9","3.1.4-r0","3.1.4-r1","3.1.4-r2","3.1.4-r3","3.1.4-r4","3.1.4-r5","3.1.5-r0","3.1.6-r0"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-3-fips-dev","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.4-r0"}]}],"versions":["3.0.4-r0","3.0.5-r0","3.0.5-r1","3.0.5-r2","3.0.5-r3","3.0.6-r0","3.0.6-r1","3.0.6-r2","3.0.6-r3","3.0.6-r4","3.0.6-r5","3.0.6-r6","3.1.1-r0","3.1.1-r1","3.1.1-r2","3.1.2-r0","3.1.2-r1","3.1.3-r0","3.1.3-r1","3.1.3-r10","3.1.3-r11","3.1.3-r12","3.1.3-r13","3.1.3-r2","3.1.3-r3","3.1.3-r4","3.1.3-r5","3.1.3-r6","3.1.3-r7","3.1.3-r8","3.1.3-r9","3.1.4-r0","3.1.4-r1","3.1.4-r2","3.1.4-r3","3.1.4-r4","3.1.4-r5","3.1.5-r0","3.1.6-r0"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-3-fips","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.4-r0"}]}],"versions":["3.0.4-r0","3.0.5-r0","3.0.5-r1","3.0.5-r2","3.0.5-r3","3.0.6-r0","3.0.6-r1","3.0.6-r2","3.0.6-r3","3.0.6-r4","3.0.6-r5","3.0.6-r6","3.1.1-r0","3.1.1-r1","3.1.1-r2","3.1.2-r0","3.1.2-r1","3.1.3-r0","3.1.3-r1","3.1.3-r10","3.1.3-r11","3.1.3-r12","3.1.3-r13","3.1.3-r2","3.1.3-r3","3.1.3-r4","3.1.3-r5","3.1.3-r6","3.1.3-r7","3.1.3-r8","3.1.3-r9","3.1.4-r0","3.1.4-r1","3.1.4-r2","3.1.4-r3","3.1.4-r4","3.1.4-r5","3.1.5-r0","3.1.6-r0"]},{"source":"osv","ecosystem":"Docker Hardened Images:Alpine:3.23","package":"cosign-3","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.4-r0"}]}],"versions":["3.0.4-r0","3.0.5-r0","3.0.5-r1","3.0.5-r2","3.0.5-r3","3.0.6-r0","3.0.6-r1","3.0.6-r2","3.0.6-r3","3.0.6-r4","3.0.6-r5","3.0.6-r6","3.1.1-r0","3.1.1-r1","3.1.1-r2","3.1.2-r0","3.1.2-r1","3.1.3-r0","3.1.3-r1","3.1.3-r10","3.1.3-r11","3.1.3-r12","3.1.3-r13","3.1.3-r2","3.1.3-r3","3.1.3-r4","3.1.3-r5","3.1.3-r6","3.1.3-r7","3.1.3-r8","3.1.3-r9","3.1.4-r0","3.1.4-r1","3.1.4-r2","3.1.4-r3","3.1.4-r4","3.1.4-r5","3.1.5-r0","3.1.6-r0"]}],"references":[{"url":"https://scout.docker.com/v/DHI-5sjj-nyr6-c2dc-4rms","tags":["advisory"]},{"url":"https://github.com/sigstore/cosign/security/advisories/GHSA-2x42-5f92-cm4x","tags":["advisory"]}],"sources":{"osv":[{"id":"DHI-5sjj-nyr6-c2dc-4rms","upstream":["GHSA-2x42-5f92-cm4x"],"title":"# Unverified Target Manifest \u0026 Bundle Blob Digests in Local OCI Bundle Verification (`GetLocalBundles`) in `cosign`","description":"# Unverified Target Manifest \u0026 Bundle Blob Digests in Local OCI Bundle Verification (`GetLocalBundles`) in `cosign`\r\n\r\n- **Target Repository:** `sigstore/cosign` (verified at `HEAD` `ef56e6999cdad185e5e155cccf1223951abfc77a`)\r\n\r\n---\r\n\r\n### Summary\r\n\r\nIn `VerifyLocalImageSignatures` (`pkg/cosign/verify.go:718-741`) and legacy `VerifyLocalImageAttestations` (`pkg/cosign/verify.go:1137-1160`), Cosign loads the target image/index from the local OCI layout via `se.SignedImage(v1.Hash{})` / `se.SignedImageIndex(v1.Hash{})` and computes its SHA-256 digest (`i.Digest()` / `ii.Digest()`) from the manifest blob on disk before verifying signatures or attestations against that computed digest.\r\n\r\nIn contrast, when `NewBundleFormat: true` is used (`verifyLocalImageAttestationsSigstoreBundle` -\u003e `GetLocalBundles` -\u003e `getLocalBundleDescriptors`, `pkg/cosign/verify.go:1820-1942`), `getLocalBundleDescriptors` reads `targetDigest = m.Digest` directly from `index.json` without reading or hashing `blobs/sha256/\u003ctargetDigest.Hex\u003e`, and `GetLocalBundles` reads `descriptor.blobPath` without verifying its SHA-256 digest against `descriptor.digest`.\r\n\r\nIf an attacker modifies the target image manifest blob `blobs/sha256/\u003ctargetDigest.Hex\u003e` in a local OCI layout (e.g., pointing it to a tampered layer) while leaving `m.Digest` unchanged in `index.json`, `GetLocalBundles` and `VerifyLocalImageAttestations` (`cosign verify-attestation --new-bundle-format --local-image \u003cPATH\u003e`) succeed and report the tampered local image as verified.\r\n\r\n---\r\n\r\n### Minimal Reproduction \u0026 Verbatim Test Output\r\n\r\n```text\r\n$ go test -v ./pkg/cosign -run 'TestGetLocalBundles_TamperedTargetManifestBlob'\r\n=== RUN   TestGetLocalBundles_TamperedTargetManifestBlob\r\n--- PASS: TestGetLocalBundles_TamperedTargetManifestBlob (0.00s)\r\nPASS\r\nok  \tgithub.com/sigstore/cosign/v3/pkg/cosign\t0.012s\r\n```\r\n\r\n---\r\n\r\n### Proposed Patch (`fix.patch`)\r\n\r\n```diff\r\ndiff --git a/pkg/cosign/verify.go b/pkg/cosign/verify.go\r\nindex 6edf6ee..a4b9011 100644\r\n--- a/pkg/cosign/verify.go\r\n+++ b/pkg/cosign/verify.go\r\n@@ -1823,6 +1823,21 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu\r\n \t\treturn nil, nil, err\r\n \t}\r\n \r\n+\tif hash != nil \u0026\u0026 len(descriptors) \u003e 0 {\r\n+\t\ttargetBlobPath := filepath.Clean(filepath.Join(path, \"blobs\", hash.Algorithm, hash.Hex))\r\n+\t\ttargetBytes, err := os.ReadFile(targetBlobPath)\r\n+\t\tif err != nil {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"reading target manifest blob %s: %w\", hash.Hex, err)\r\n+\t\t}\r\n+\t\tactualTargetHash, _, err := v1.SHA256(bytes.NewReader(targetBytes))\r\n+\t\tif err != nil {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"hashing target manifest blob %s: %w\", hash.Hex, err)\r\n+\t\t}\r\n+\t\tif actualTargetHash != *hash {\r\n+\t\t\treturn nil, nil, fmt.Errorf(\"target manifest digest mismatch: index.json declares %s, but blob hashes to %s\", *hash, actualTargetHash)\r\n+\t\t}\r\n+\t}\r\n+\r\n \tbundles := make([]*sgbundle.Bundle, 0, len(descriptors))\r\n \tfor _, descriptor := range descriptors {\r\n \t\tbundleBytes, err := os.ReadFile(filepath.Join(path, descriptor.blobPath))\r\n@@ -1831,6 +1846,12 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu\r\n \t\t\tcontinue\r\n \t\t}\r\n \r\n+\t\tactualBundleHash, _, err := v1.SHA256(bytes.NewReader(bundleBytes))\r\n+\t\tif err != nil || actualBundleHash != descriptor.digest {\r\n+\t\t\tui.Warnf(context.Background(), \"Bundle blob %s digest mismatch: got %s\", descriptor.digest.Hex, actualBundleHash.Hex)\r\n+\t\t\tcontinue\r\n+\t\t}\r\n+\r\n \t\tpb := \u0026protobundle.Bundle{}\r\n \t\tif err := protojson.Unmarshal(bundleBytes, pb); err != nil {\r\n \t\t\tui.Warnf(context.Background(), \"Failed to unmarshal bundle %s: %v\", descriptor.digest.Hex, err)\r\ndiff --git a/pkg/cosign/verify_test.go b/pkg/cosign/verify_test.go\r\nindex b7ac541..55e182d 100644\r\n--- a/pkg/cosign/verify_test.go\r\n+++ b/pkg/cosign/verify_test.go\r\n@@ -2896,3 +2896,32 @@ func TestVerifyImageSignatureWithBundleBodyMissingHash(t *testing.T) {\r\n \t\t})\r\n \t}\r\n }\r\n+\r\n+func TestGetLocalBundles_TamperedTargetManifestBlob(t *testing.T) {\r\n+\ttmp := createV3BundleLayout(t)\r\n+\r\n+\tp, err := ggcrlayout.FromPath(tmp)\r\n+\trequire.NoError(t, err)\r\n+\tii, err := p.ImageIndex()\r\n+\trequire.NoError(t, err)\r\n+\tidxManifest, err := ii.IndexManifest()\r\n+\trequire.NoError(t, err)\r\n+\r\n+\tvar targetDigest v1.Hash\r\n+\tfor _, m := range idxManifest.Manifests {\r\n+\t\tif m.Annotations[\"kind\"] == \"dev.cosignproject.cosign/image\" {\r\n+\t\t\ttargetDigest = m.Digest\r\n+\t\t\tbreak\r\n+\t\t}\r\n+\t}\r\n+\trequire.NotEmpty(t, targetDigest.Hex)\r\n+\r\n+\t// Tamper with the target image manifest blob on disk without updating index.json\r\n+\ttargetBlobPath := filepath.Join(tmp, \"blobs\", \"sha256\", targetDigest.Hex)\r\n+\terr = os.WriteFile(targetBlobPath, []byte(`{\"schemaVersion\":2,\"mediaType\":\"application/vnd.oci.image.manifest.v1+json\",\"Tampered\":true}`), 0644)\r\n+\trequire.NoError(t, err)\r\n+\r\n+\t_, _, err = GetLocalBundles(tmp)\r\n+\trequire.Error(t, err)\r\n+\tassert.Contains(t, err.Error(), \"target manifest digest mismatch\")\r\n+}\r\n```\r\n","status":"published","published":"2026-12-04T14:13:52Z","modified":"2026-12-04T14:30:11.944375541Z","updated_at":"2026-12-04T14:45:23.964298Z"}]}}
