Skip to content

Conversation

@haydentherapper
Copy link
Contributor

@haydentherapper haydentherapper commented Aug 27, 2025

Summary

This will indirectly add support for signing with Rekor v2, since signing will be handled by sigstore-go rather than Cosign.

This also brings sign/attest up to par with the recent changes to sign-blob/attest-blob, including signing with a key and providing a path to a trusted root when providing a signing config to verify after signing.

This feature is gated behind one of two signing config flags, which in a later version of Cosign will be flipped to on by default. Once this is the default, we'll be able to refactor the core signing and verification logic in Cosign, largely replacing it with sigstore-go.

Fixes #4324

Release Note

Documentation

@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 0% with 242 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.32%. Comparing base (2ef6022) to head (81e920f).
⚠️ Report is 503 commits behind head on main.

Files with missing lines Patch % Lines
cmd/cosign/cli/sign/sign.go 0.00% 85 Missing ⚠️
cmd/cosign/cli/attest/attest.go 0.00% 69 Missing ⚠️
cmd/cosign/cli/attest.go 0.00% 26 Missing ⚠️
cmd/cosign/cli/sign.go 0.00% 26 Missing ⚠️
cmd/cosign/cli/options/attest.go 0.00% 13 Missing ⚠️
cmd/cosign/cli/options/sign.go 0.00% 13 Missing ⚠️
cmd/cosign/cli/attest_blob.go 0.00% 3 Missing ⚠️
cmd/cosign/cli/signblob.go 0.00% 3 Missing ⚠️
cmd/cosign/cli/options/attest_blob.go 0.00% 2 Missing ⚠️
cmd/cosign/cli/options/signblob.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4371      +/-   ##
==========================================
- Coverage   40.10%   34.32%   -5.78%     
==========================================
  Files         155      217      +62     
  Lines       10044    15518    +5474     
==========================================
+ Hits         4028     5327    +1299     
- Misses       5530     9500    +3970     
- Partials      486      691     +205     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haydentherapper haydentherapper force-pushed the sc-sign-attest branch 2 times, most recently from 1d07438 to 8dbe6bf Compare August 27, 2025 23:15
@haydentherapper haydentherapper changed the title Sc sign attest Add support for SigningConfig in sign/attest Aug 27, 2025
@haydentherapper haydentherapper marked this pull request as ready for review August 27, 2025 23:44
@haydentherapper haydentherapper requested a review from a team as a code owner August 27, 2025 23:44
@haydentherapper
Copy link
Contributor Author

Putting this up for an early review. Only the last commit is new, the first two commits will be merged in other open PRs. I also am currently doing some manual testing.

@haydentherapper
Copy link
Contributor Author

haydentherapper commented Aug 28, 2025

Testing against staging with a local zot instance:

Sign:

cosign sign --new-bundle-format --use-signing-config --yes localhost:5050/busybox:latest
cosign verify --new-bundle-format --certificate-identity=$email --certificate-oidc-issuer=https://accounts.google.com --use-signed-timestamps localhost:5050/busybox:latest

oras blob fetch --output - localhost:5050/busybox@sha256:2e6e693c1a62b4f9e006eead11076f39b5a7940a71f4c608324568fe12f396fc | jq .

{
  "mediaType": "application/vnd.dev.sigstore.bundle.v0.3+json",
  "verificationMaterial": {
    "certificate": {
      "rawBytes": "MIICzjCCAlOgAwIBAgIUF/ZyPksSsstDsqaZISaWcDBL684wCgYIKoZIzj0EAwMwNzEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MR4wHAYDVQQDExVzaWdzdG9yZS1pbnRlcm1lZGlhdGUwHhcNMjUwODI4MDAwNDMwWhcNMjUwODI4MDAxNDMwWjAAMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEt2xsbKVrtLu0YZxn/TJqlu05/vSnRXRUsCzhGsbJTnkl9g9vRnh113MXvXZ+8EwPK3F4wes7fv4q8rJY+fe4XqOCAXIwggFuMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAdBgNVHQ4EFgQU5U00OtEMmKLnP/Ma2cHO9lLDXUQwHwYDVR0jBBgwFoAUcYYwphR8Ym/599b0BRp/X//rb6wwIwYDVR0RAQH/BBkwF4EVaGJsYXV6dmVybkBnb29nbGUuY29tMCkGCisGAQQBg78wAQEEG2h0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbTArBgorBgEEAYO/MAEIBB0MG2h0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbTCBiQYKKwYBBAHWeQIEAgR7BHkAdwB1ACswvNxoiMni4dgmKV50H0g5MZYC8pwzy15DQP6yrIZ6AAABmO39gk8AAAQDAEYwRAIgRC0J8n46B7zf2+5uYPHvqUO4qPSMPvmzupDuUyCjeFcCIHcVR3wdAEL/NJqq1PVRHXbiAgFHWQiV9jl1KHU8/3HoMAoGCCqGSM49BAMDA2kAMGYCMQC1UPOz7HdO9RbHz37o7ogyDKLC2lFUvyJV8AIXHFuO79K+W3RlFHcOxicBXT23ERUCMQDKv6MJzilBEdbVRL8JamO79ASQkL0yaY8jEAbx2vyAkM+bRDSDPN3VbHFcGoXeKyA="
    },
    "tlogEntries": [
      {
        "logIndex": "12653",
        "logId": {
          "keyId": "KfSiSX2iRLyhK62SUVL47vVcqqRx/RAewpKJm8IdZTo="
        },
        "kindVersion": {
          "kind": "dsse",
          "version": "0.0.2"
        },
        "inclusionProof": {
          "logIndex": "12653",
          "rootHash": "fYshRW6nXqcskwfN7nsKsSafcKRgg2ecRB2esuCvfsY=",
          "treeSize": "12654",
          "hashes": [
            "MVX3t35pWRVJT8kI8E8VhzXEtaMiBW5X+yTg+c5rRZ8=",
            "xo0nSM6X1VP86U0LV0080T85/1GhoNbKhKWqXs6ittw=",
            "kB/wdWX34RvwCwwrx8hZhzxqDNTmAGNfDsgVOhkWq1I=",
            "vXnnwpJ5OqciN9qMZwmmYK4xEI028u3zHYDuTYmc1co=",
            "OMXJPMCyNGqHkMduha23XycScArnTg26vxwUXJKNVMI=",
            "+frQeMrCfT9QFlGbcibAql8UWJFZmufwvKNxgbpVCA4=",
            "0KNqXR/+75uSLph/Fx2weSQRzJL39gQLZbIvS42Ol+U=",
            "pXaQv2zTqk7DxhnCqnfuzVrpMtX5u3D9hF1QmrEewVY="
          ],
          "checkpoint": {
            "envelope": "log2025-al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iODViYjZkYmE1NzBlNDY5OGMzOTk4ZWNhNmYwZmMyY2NiNjA1NzVhNTYzZWE3NCJ9fV0sInByZWRpY2F0ZVR5cGUiOiJodHRwczovL3NpZ3N0b3JlLmRldi9jb3NpZ24vc2lnbi92MSJ9",
    "payloadType": "application/vnd.in-toto+json",
    "signatures": [
      {
        "sig": "MEUCIDxub2b83EhM+W/INJbTNy2qXVercHDScgmazxfIBg5jAiEAy1nC6kILoVlHsIShnCWQhpVc782r8TNeezvkQOsY0Xo="
      }
    ]
  }
}

Attest:

cosign attest --predicate predicate.json --new-bundle-format --use-signing-config --yes localhost:5050/busybox:latest
cosign verify-attestation --new-bundle-format --certificate-identity=$email --certificate-oidc-issuer=https://accounts.google.com --use-signed-timestamps --check-claims localhost:5050/busybox:latest

oras discover localhost:5050/busybox:latest

localhost:5050/busybox@sha256:ab33eacc8251e3807b85bb6dba570e4698c3998eca6f0fc2ccb60575a563ea74
└── application/vnd.dev.sigstore.bundle.v0.3+json
    └── sha256:35e2d0bf2dfcad705b31b1d97f4c54cecbae6ef091b35a42d80e28838f47e3cf

oras blob fetch --output - localhost:5050/busybox@sha256:5a7f96b09c6f4583801e1a79ae39b9d729fac8149f8789cfb2a0cb9066d1e71f | jq .
# A bundle is there!

@haydentherapper
Copy link
Contributor Author

haydentherapper commented Aug 28, 2025

Note to reviewers: Going to take a pass over trying to reduce duplication.

Edit: Reviewing the code, I'd rather not try to reduce duplication for now between sign and attest. These commands will be nearly identical post-Cosign v3, so I'd rather just remove one later on then try to determine a good API for shared logic between the two right now.

@haydentherapper haydentherapper force-pushed the sc-sign-attest branch 4 times, most recently from a789a34 to 4f9d05d Compare September 3, 2025 19:26
steiza
steiza previously approved these changes Sep 4, 2025
Copy link
Member

@steiza steiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how all the pieces are clicking together! Just a few minor, non-blocking comments.

This will indirectly add support for signing with Rekor v2, since
signing will be handled by sigstore-go rather than Cosign.

This also brings sign/attest up to par with sign-blob/attest-blob with
respect to signing with a key and providing a trusted root when
providing a signing config.

This feature is gated behind one of two signing config flags, which in a
later version of Cosign will be flipped to on by default.

Signed-off-by: Hayden <8418760+haydentherapper@users.noreply.github.com>
--signing-config and --use-signing-config are now mutually exclusive.

TrustedMaterial and SigningConfig are set in the same line as fetching
the trusted root and signing config.

Signed-off-by: Hayden <8418760+haydentherapper@users.noreply.github.com>
Copy link
Member

@steiza steiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@haydentherapper haydentherapper merged commit a2cbeda into sigstore:main Sep 4, 2025
29 checks passed
@haydentherapper haydentherapper deleted the sc-sign-attest branch September 4, 2025 20:32
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Sep 16, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cosign](https://github.com/sigstore/cosign) | minor | `2.5.3` -> `2.6.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>sigstore/cosign (cosign)</summary>

### [`v2.6.0`](https://github.com/sigstore/cosign/blob/HEAD/CHANGELOG.md#v260)

[Compare Source](sigstore/cosign@v2.5.3...v2.6.0)

v2.6.0 introduces a number of new features, including:

- Signing an in-toto statement rather than Cosign constructing one from a predicate, along with verifying a statement's subject using a digest and digest algorithm rather than providing a file reference ([#&#8203;4306](sigstore/cosign#4306))
- Uploading a signature and its verification material (a ["bundle"](https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_bundle.proto)) as an OCI Image 1.1 referring artifact, completing [#&#8203;3927](sigstore/cosign#3927) ([#&#8203;4316](sigstore/cosign#4316))
- Providing service URLs for signing and attesting using a [SigningConfig](https://github.com/sigstore/protobuf-specs/blob/4df5baadcdb582a70c2bc032e042c0a218eb3841/protos/sigstore_trustroot.proto#L185). Note that this is required when using a [Rekor v2](https://github.com/sigstore/rekor-tiles) instance ([#&#8203;4319](sigstore/cosign#4319))

Example generation and verification of a signed in-toto statement:

```
cosign attest-blob --new-bundle-format=true --bundle="digest-key-test.sigstore.json" --key="cosign.key" --statement="../sigstore-go/examples/sigstore-go-signing/intoto.txt"
cosign verify-blob-attestation --bundle="digest-key-test.sigstore.json" --key=cosign.pub --type=unused --digest="b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" --digestAlg="sha256"
```

Example container signing and verification using the new bundle format and referring artifacts:

```
cosign sign --new-bundle-format=true ghcr.io/user/alpine@sha256:a19367999603840546b8612572e338ec076c6d1f2fec61760a9e11410f546733
cosign verify --new-bundle-format=true ghcr.io/user/alpine@sha256:a19367999603840546b8612572e338ec076c6d1f2fec61760a9e11410f546733
```

Example usage of a signing config provided by the public good instance's TUF repository:

```
cosign sign-blob --use-signing-config --bundle sigstore.json README.md
cosign verify-blob --new-bundle-format --bundle sigstore.json --certificate-identity $EMAIL --certificate-oidc-issuer $ISSUER --use-signed-timestamps README.md
```

v2.6.0 leverages sigstore-go's signing and verification APIs gated behind these new flags. In an upcoming major release, we will be
updating Cosign to default to producing and consuming bundles to align with all other Sigstore SDKs.

#### Features

- Add to `attest-blob` the ability to supply a complete in-toto statement, and add to `verify-blob-attestation` the ability to verify with just a digest ([#&#8203;4306](sigstore/cosign#4306))
- Have cosign sign support bundle format ([#&#8203;4316](sigstore/cosign#4316))
- Add support for SigningConfig for sign-blob/attest-blob, support Rekor v2 ([#&#8203;4319](sigstore/cosign#4319))
- Add support for SigningConfig in sign/attest ([#&#8203;4371](sigstore/cosign#4371))
- Support self-managed keys when signing with sigstore-go ([#&#8203;4368](sigstore/cosign#4368))
- Don't require timestamps when verifying with a key ([#&#8203;4337](sigstore/cosign#4337))
- Don't load content from TUF if trusted root path is specified ([#&#8203;4347](sigstore/cosign#4347))
- Add a terminal spinner while signing with sigstore-go ([#&#8203;4402](sigstore/cosign#4402))
- Require exclusively a SigningConfig or service URLs when signing ([#&#8203;4403](sigstore/cosign#4403))
- Remove SHA256 assumption in sign-blob/verify-blob ([#&#8203;4050](sigstore/cosign#4050))
- Bump sigstore-go, support alternative hash algorithms with keys ([#&#8203;4386](sigstore/cosign#4386))

#### Breaking API Changes

- `sign.SignerFromKeyOpts` no longer generates a key. Instead, it returns whether or not the client needs to generate a key, and if so, clients
  should call `sign.KeylessSigner`. This allows clients to more easily manage key generation.

#### Bug Fixes

- Verify subject with bundle only when checking claims ([#&#8203;4320](sigstore/cosign#4320))
- Fixes to cosign sign / verify for the new bundle format ([#&#8203;4346](sigstore/cosign#4346))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMTMuNSIsInVwZGF0ZWRJblZlciI6IjQxLjExMy41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SigningConfig for Sign and Attest

2 participants