GHSA-2x42-5f92-cm4x
Unverified Target Manifest & Bundle Blob Digests in Local OCI Bundle Verification (GetLocalBundles) in cosign Target…
- Scores
- UnknownNo source reports a CVSS or EPSS score yet.
- Exploitation
- UnknownNo source reports exploitation yet.
- Listed fix
- None listedNo source lists a fixed version in its version data.Check the description and references.
Overview
Unverified Target Manifest & Bundle Blob Digests in Local OCI Bundle Verification (GetLocalBundles) in cosign
- Target Repository:
sigstore/cosign(verified atHEADef56e6999cdad185e5e155cccf1223951abfc77a)
Summary
In 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.
In contrast, when NewBundleFormat: true is used (verifyLocalImageAttestationsSigstoreBundle -> GetLocalBundles -> getLocalBundleDescriptors, pkg/cosign/verify.go:1820-1942), getLocalBundleDescriptors reads targetDigest = m.Digest directly from index.json without reading or hashing blobs/sha256/<targetDigest.Hex>, and GetLocalBundles reads descriptor.blobPath without verifying its SHA-256 digest against descriptor.digest.
If an attacker modifies the target image manifest blob blobs/sha256/<targetDigest.Hex> 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 <PATH>) succeed and report the tampered local image as verified.
Minimal Reproduction & Verbatim Test Output
$ go test -v ./pkg/cosign -run 'TestGetLocalBundles_TamperedTargetManifestBlob'
=== RUN TestGetLocalBundles_TamperedTargetManifestBlob
--- PASS: TestGetLocalBundles_TamperedTargetManifestBlob (0.00s)
PASS
ok github.com/sigstore/cosign/v3/pkg/cosign 0.012s
Proposed Patch (fix.patch)
diff --git a/pkg/cosign/verify.go b/pkg/cosign/verify.go
index 6edf6ee..a4b9011 100644
--- a/pkg/cosign/verify.go
+++ b/pkg/cosign/verify.go
@@ -1823,6 +1823,21 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu
return nil, nil, err
}
+ if hash != nil && len(descriptors) > 0 {
+ targetBlobPath := filepath.Clean(filepath.Join(path, "blobs", hash.Algorithm, hash.Hex))
+ targetBytes, err := os.ReadFile(targetBlobPath)
+ if err != nil {
+ return nil, nil, fmt.Errorf("reading target manifest blob %s: %w", hash.Hex, err)
+ }
+ actualTargetHash, _, err := v1.SHA256(bytes.NewReader(targetBytes))
+ if err != nil {
+ return nil, nil, fmt.Errorf("hashing target manifest blob %s: %w", hash.Hex, err)
+ }
+ if actualTargetHash != *hash {
+ return nil, nil, fmt.Errorf("target manifest digest mismatch: index.json declares %s, but blob hashes to %s", *hash, actualTargetHash)
+ }
+ }
+
bundles := make([]*sgbundle.Bundle, 0, len(descriptors))
for _, descriptor := range descriptors {
bundleBytes, err := os.ReadFile(filepath.Join(path, descriptor.blobPath))
@@ -1831,6 +1846,12 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu
continue
}
+ actualBundleHash, _, err := v1.SHA256(bytes.NewReader(bundleBytes))
+ if err != nil || actualBundleHash != descriptor.digest {
+ ui.Warnf(context.Background(), "Bundle blob %s digest mismatch: got %s", descriptor.digest.Hex, actualBundleHash.Hex)
+ continue
+ }
+
pb := &protobundle.Bundle{}
if err := protojson.Unmarshal(bundleBytes, pb); err != nil {
ui.Warnf(context.Background(), "Failed to unmarshal bundle %s: %v", descriptor.digest.Hex, err)
diff --git a/pkg/cosign/verify_test.go b/pkg/cosign/verify_test.go
index b7ac541..55e182d 100644
--- a/pkg/cosign/verify_test.go
+++ b/pkg/cosign/verify_test.go
@@ -2896,3 +2896,32 @@ func TestVerifyImageSignatureWithBundleBodyMissingHash(t *testing.T) {
})
}
}
+
+func TestGetLocalBundles_TamperedTargetManifestBlob(t *testing.T) {
+ tmp := createV3BundleLayout(t)
+
+ p, err := ggcrlayout.FromPath(tmp)
+ require.NoError(t, err)
+ ii, err := p.ImageIndex()
+ require.NoError(t, err)
+ idxManifest, err := ii.IndexManifest()
+ require.NoError(t, err)
+
+ var targetDigest v1.Hash
+ for _, m := range idxManifest.Manifests {
+ if m.Annotations["kind"] == "dev.cosignproject.cosign/image" {
+ targetDigest = m.Digest
+ break
+ }
+ }
+ require.NotEmpty(t, targetDigest.Hex)
+
+ // Tamper with the target image manifest blob on disk without updating index.json
+ targetBlobPath := filepath.Join(tmp, "blobs", "sha256", targetDigest.Hex)
+ err = os.WriteFile(targetBlobPath, []byte(`{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","Tampered":true}`), 0644)
+ require.NoError(t, err)
+
+ _, _, err = GetLocalBundles(tmp)
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "target manifest digest mismatch")
+}
Affected
Packages 8
| Package | Affected | Fixed |
|---|---|---|
cosign-2-devDocker 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 less2.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-devDocker 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 less2.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-fipsDocker 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 less2.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-2Docker 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 less2.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-devDocker 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 less3.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-devDocker 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 less3.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-fipsDocker 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 less3.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-3Docker 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 less3.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-5sjj-nyr6-c2dc-4rmsNo score
# Unverified Target Manifest & Bundle Blob Digests in Local OCI Bundle Verification (`GetLocalBundles`) in `cosign`
Unverified Target Manifest & Bundle Blob Digests in Local OCI Bundle Verification (GetLocalBundles) in cosign
- Target Repository:
sigstore/cosign(verified atHEADef56e6999cdad185e5e155cccf1223951abfc77a)
Summary
In 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.
In contrast, when NewBundleFormat: true is used (verifyLocalImageAttestationsSigstoreBundle -> GetLocalBundles -> getLocalBundleDescriptors, pkg/cosign/verify.go:1820-1942), getLocalBundleDescriptors reads targetDigest = m.Digest directly from index.json without reading or hashing blobs/sha256/<targetDigest.Hex>, and GetLocalBundles reads descriptor.blobPath without verifying its SHA-256 digest against descriptor.digest.
If an attacker modifies the target image manifest blob blobs/sha256/<targetDigest.Hex> 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 <PATH>) succeed and report the tampered local image as verified.
Minimal Reproduction & Verbatim Test Output
$ go test -v ./pkg/cosign -run 'TestGetLocalBundles_TamperedTargetManifestBlob'
=== RUN TestGetLocalBundles_TamperedTargetManifestBlob
--- PASS: TestGetLocalBundles_TamperedTargetManifestBlob (0.00s)
PASS
ok github.com/sigstore/cosign/v3/pkg/cosign 0.012s
Proposed Patch (fix.patch)
diff --git a/pkg/cosign/verify.go b/pkg/cosign/verify.go
index 6edf6ee..a4b9011 100644
--- a/pkg/cosign/verify.go
+++ b/pkg/cosign/verify.go
@@ -1823,6 +1823,21 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu
return nil, nil, err
}
+ if hash != nil && len(descriptors) > 0 {
+ targetBlobPath := filepath.Clean(filepath.Join(path, "blobs", hash.Algorithm, hash.Hex))
+ targetBytes, err := os.ReadFile(targetBlobPath)
+ if err != nil {
+ return nil, nil, fmt.Errorf("reading target manifest blob %s: %w", hash.Hex, err)
+ }
+ actualTargetHash, _, err := v1.SHA256(bytes.NewReader(targetBytes))
+ if err != nil {
+ return nil, nil, fmt.Errorf("hashing target manifest blob %s: %w", hash.Hex, err)
+ }
+ if actualTargetHash != *hash {
+ return nil, nil, fmt.Errorf("target manifest digest mismatch: index.json declares %s, but blob hashes to %s", *hash, actualTargetHash)
+ }
+ }
+
bundles := make([]*sgbundle.Bundle, 0, len(descriptors))
for _, descriptor := range descriptors {
bundleBytes, err := os.ReadFile(filepath.Join(path, descriptor.blobPath))
@@ -1831,6 +1846,12 @@ func GetLocalBundles(path string, bundleOpts ...sgbundle.Option) ([]*sgbundle.Bu
continue
}
+ actualBundleHash, _, err := v1.SHA256(bytes.NewReader(bundleBytes))
+ if err != nil || actualBundleHash != descriptor.digest {
+ ui.Warnf(context.Background(), "Bundle blob %s digest mismatch: got %s", descriptor.digest.Hex, actualBundleHash.Hex)
+ continue
+ }
+
pb := &protobundle.Bundle{}
if err := protojson.Unmarshal(bundleBytes, pb); err != nil {
ui.Warnf(context.Background(), "Failed to unmarshal bundle %s: %v", descriptor.digest.Hex, err)
diff --git a/pkg/cosign/verify_test.go b/pkg/cosign/verify_test.go
index b7ac541..55e182d 100644
--- a/pkg/cosign/verify_test.go
+++ b/pkg/cosign/verify_test.go
@@ -2896,3 +2896,32 @@ func TestVerifyImageSignatureWithBundleBodyMissingHash(t *testing.T) {
})
}
}
+
+func…
- Record
DHI-5sjj-nyr6-c2dc-4rms- Updated
- 2026-12-04
The JSON record also has the rest of 1 source description.
History
Recorded by Every CVE
| Day | Changed | Sources |
|---|---|---|
| First indexed | OSV |
Upstream dates may differ.