Improper Certificate Validation in Cosign

Description

Impact

Cosign can be manipulated to claim that an entry for a signature exists in the Rekor transparency log even if it doesn't. This requires the attacker to have pull and push permissions for the signature in OCI. This can happen with both standard signing with a keypair and "keyless signing" with Fulcio.

Signing with a keypair

<details>

To reproduce this vulnerability, create a keypair and sign an image. Don't store the signature in Rekor:

$ cosign generate-key-pair       
$ cosign sign --key cosign.key IMAGE

If an attacker has access to the signature in OCI, they can manipulate cosign into believing the entry was stored in Rekor even though it wasn't. To accomplish this, the attacker needs to:

  1. Pull the signature image
  2. Annotate the signature image with any valid Rekor bundle under the dev.sigstore.cosign/bundle annotation
  3. Push the signature image back to OCI

Verification then prints out the following:

$ cosign verify [--key]  [IMAGE]

Verification for [IMAGE] --
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - Existence of the claims in the transparency log was verified offline
  - The signatures were verified against the specified public key
  - Any certificates were verified against the Fulcio roots.

[…]

The claim that Existence of the claims in the transparency log was verified offline is inaccurate since an entry for this image doesn't exist in the log.
The claim that Any certificates were verified against the Fulcio roots. is technically correct but since there were no certificates that should be explicitly called out.

</details>

"Keyless signing" with an OIDC flow

<details>

To reproduce this vulnerability, sign the image with a Fulcio identity. Don't store the signature in Rekor:

$ COSIGN_EXPERIMENTAL=1 cosign sign IMAGE
[...]
IMAGE appears to be a private repository, please confirm uploading to the transparency log at &quot;https://rekor.sigstore.dev&quot; [Y/N]: n

Then, create a keypair and sign the image again. Store an entry for the signature in Rekor:

$ cosign generate-key-pair       
$ COSIGN_EXPERIMENTAL=1 cosign sign --key cosign.key IMAGE

Enter password for private key: IMAGE appears to be a private repository, please confirm uploading to the transparency log at &quot;https://rekor.sigstore.dev&quot; [Y/N]: y

If an attacker has access to the signature in OCI, they can manipulate cosign into believing the entry was stored in Rekor even though it wasn't. To accomplish this, the attacker needs to:

  1. Pull the signature image
  2. Copy the rekor bundle from the second signature into the first signature under the dev.sigstore.cosign/bundle annotation
  3. Push the signature image back to OCI

Note: For this to work, both signatures must occur during the valid lifespan of the certificate (~20 minutes).

Verification then prints out the following:

$ cosign verify [--key]  [IMAGE]

Verification for [IMAGE] --
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - Existence of the claims in the transparency log was verified offline
  - The signatures were verified against the specified public key
  - Any certificates were verified against the Fulcio roots.

[…]

The claim that Existence of the claims in the transparency log was verified offline is inaccurate since an entry for this image doesn't exist in the log.

The claim that Any certificates were verified against the Fulcio roots. is technically correct but since there were no certificates that should be explicitly called out.

</details>

Patches

The vulnerability has been patched in v1.5.2 of cosign.

The signature in the signedEntryTimestamp provided by Rekor is now compared to the signature that is being verified. If these don't match, then an error is returned. If a valid bundle is copied to a different signature, verification should fail.

Cosign output now only informs the user that certificates were verified if a certificate was in fact verified.

Workarounds

The only workaround is upgrading.

For more information

If you have any questions or comments about this advisory:
* Open an issue in cosign
* Send us a message on Slack. Invite link here.

Thank you

Thank you to @mtrmac for finding and reporting this vulnerability.

Thank you to everyone who worked on fixing this:
* @nsmith5
* @znewman01
* @dlorenc
* @mattmoor
* @priyawadhwa

Basic information

Type
reviewed
Severity
low
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2022-02-22 19:34:09 UTC
Updated
2023-02-03 05:06:13 UTC
GitHub reviewed
2022-02-22 19:34:09 UTC
NVD published
2022-02-18

EPSS Score

Score Percentile
0.05% 16.51%

CVSS Scores

Base score Version Severity Vector
3.3 3.1
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N Click to expand
Attack vector (AV:L)
They already need access on the box, or another person has to do something wrong; it’s not a remote drive-by.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:L)
A normal user session is enough; they don’t have to be admin.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:N)
Doesn’t really leak secrets in a meaningful way.
Integrity (I:L)
Attackers could change some data, but it’s limited—not everything goes.
Availability (A:N)
Service keeps running; no real outage angle.

Identifiers

CWEs

CWE id Name
CWE-295 Improper Certificate Validation

Credits

  • znewman01 (analyst)
  • dlorenc (analyst)
  • mattmoor (analyst)
  • priyawadhwa (analyst)
  • mtrmac (analyst)
  • nsmith5 (analyst)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
go github.com/sigstore/cosign < 1.5.2 1.5.2

References

cvelogic Threat Intelligence