Repository navigation
Require new bundle format for sign-blob - #5083
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5083 +/- ##
==========================================
+ Coverage 40.10% 47.11% +7.00%
==========================================
Files 155 209 +54
Lines 10044 11795 +1751
==========================================
+ Hits 4028 5557 +1529
- Misses 5530 6238 +708
+ Partials 486 0 -486 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3f4e3a7 to
c2c04ae
Compare
9e84657 to
5cf96cf
Compare
5e22f54 to
73c166d
Compare
0994455 to
5dd0fb5
Compare
9b30c83 to
33ec67e
Compare
7323347 to
7fb5d4b
Compare
7fb5d4b to
c675ba9
Compare
TestingThe following commands can be used to test the changes in this PR. SetupBefore running the tests, ensure that you have generated a local test keypair (which is used for key-based tests): # Generate a keypair (writes to cosign.key and cosign.pub)
cosign generate-key-pair1. TUF-provided Signing Config & Trusted RootVerify that a TUF-provided signing config and trusted root are resolved correctly for keyless operations and key-based, certificate-backed operations: Keyless OperationsBlob signing & verification# Sign a blob to generate a bundle
cosign sign-blob --bundle blob.bundle [BLOB_FILE]
# Verify the blob using the bundle and TUF trusted root
cosign verify-blob --bundle blob.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]Key-based / Certificate-backed OperationsKey-based, certificate-backed signing & verification# Sign a blob using local key and request Fulcio certificate using TUF signing config
cosign sign-blob --key cosign.key --issue-certificate --bundle blob.bundle [BLOB_FILE]
# Verify using TUF trusted root and identity checks
cosign verify-blob --bundle blob.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]Key-based signing with transparency log and RFC 3161 timestamp# Sign a blob using key and request log entry/timestamp
cosign sign-blob --key cosign.key --bundle blob.bundle [BLOB_FILE]
# Verify the blob bundle (verifying the signature, log proof and RFC 3161 timestamp against TUF trusted root)
cosign verify-blob --key cosign.pub --use-signed-timestamps --bundle blob.bundle [BLOB_FILE]2. Explicit Local Signing Config & Trusted RootVerify that explicitly provided local config and trusted root files are loaded and utilized correctly: Keyless OperationsBlob signing & verification# Sign a blob using local signing config and trusted root files
cosign sign-blob --signing-config [PATH_TO_SIGNING_CONFIG] --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob.bundle [BLOB_FILE]
# Verify the blob using an explicit trusted root file
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]Key-based OperationsKey-based, certificate-backed signing & verification# Sign a blob using local key and request Fulcio certificate using local signing config
cosign sign-blob --key cosign.key --issue-certificate --signing-config [PATH_TO_SIGNING_CONFIG] --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob.bundle [BLOB_FILE]
# Verify using local trusted root file and identity checks
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]Key-based signing with transparency log and RFC 3161 timestamp# Sign a blob using key and request log entry/timestamp via local signing config
cosign sign-blob --key cosign.key --signing-config [PATH_TO_SIGNING_CONFIG] --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob.bundle [BLOB_FILE]
# Verify the blob bundle against local trusted root file (including the RFC 3161 timestamp)
cosign verify-blob --key cosign.pub --trusted-root [PATH_TO_TRUSTED_ROOT] --use-signed-timestamps --bundle blob.bundle [BLOB_FILE]Service Omission Tests (Config-driven behavior)Verify that omitting specific services in the signing config successfully skips their use during signing: Omitting Rekor (Skips log upload)# 1. Generate a signing config file without Rekor configured
cosign signing-config create --with-default-services --no-default-rekor --out signing-config-no-rekor.json
# 2. Sign a blob (succeeds without attempting log upload; generated bundle will not contain a log entry)
cosign sign-blob --signing-config signing-config-no-rekor.json --bundle blob-no-rekor.bundle [BLOB_FILE]
# 3. Verify the bundle (should FAIL by default due to missing log entry/SET proof)
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob-no-rekor.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]
# 4. Verify the bundle with tlog bypassed (should SUCCEED; the certificate is checked against the current time, so run this within its validity window or add --use-signed-timestamps)
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob-no-rekor.bundle --insecure-ignore-tlog --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]Omitting TSA (No RFC 3161 timestamp in the bundle)# 1. Generate a signing config file without TSA configured
cosign signing-config create --with-default-services --no-default-tsa --out signing-config-no-tsa.json
# 2. Sign a blob (generated bundle will not contain a timestamp)
cosign sign-blob --signing-config signing-config-no-tsa.json --bundle blob-no-tsa.bundle [BLOB_FILE]
# 3. Verify the bundle (should SUCCEED; falls back to using the tlog integrated time to verify certificate expiry)
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob-no-tsa.bundle --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]
# 4. Verify the bundle requiring a signed timestamp (should FAIL due to missing timestamp)
cosign verify-blob --trusted-root [PATH_TO_TRUSTED_ROOT] --bundle blob-no-tsa.bundle --use-signed-timestamps --certificate-identity [IDENTITY] --certificate-oidc-issuer [ISSUER] [BLOB_FILE]3. Simple Key-based Signing & Verification (No services)Verify that simple key-based operations (which do not interact with Fulcio, Rekor, or a timestamp authority) work cleanly: # Sign a blob using a private key and no signing config (generates a simple bundle without log/timestamp verification material)
cosign sign-blob --key cosign.key --use-signing-config=false --bundle blob.bundle [BLOB_FILE]
# Verify the blob using the public key and bundle (the bundle has no log entry, so the tlog check has to be skipped)
cosign verify-blob --key cosign.pub --insecure-ignore-tlog --bundle blob.bundle [BLOB_FILE]4. CLI Flag Validations (Negative Testing)Verify that the CLI rejects removed flags and enforces mandatory new arguments: # 1. Rejects removed flags (should fail with unknown flag errors)
cosign sign-blob --rekor-url [URL] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --timestamp-server-url [URL] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --tlog-upload=false --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --new-bundle-format --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --rfc3161-timestamp [TS_PATH] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --output-signature [SIG_PATH] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --output-certificate [CERT_PATH] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --output [OUTPUT_PATH] --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --b64=false --bundle blob.bundle [BLOB_FILE]
# 2. Enforces a signing config with a Fulcio CA for keyless and certificate-based signing
# (should fail with "keyless signing requires a signing config with a Fulcio certificate authority"
# and "certificate-based signing requires a signing config with a Fulcio certificate authority", respectively)
cosign sign-blob --use-signing-config=false --bundle blob.bundle [BLOB_FILE]
cosign sign-blob --key cosign.key --issue-certificate --use-signing-config=false --bundle blob.bundle [BLOB_FILE]
# Same check with a signing config that has services but no Fulcio CA (should fail with the keyless message)
cosign signing-config create --with-default-services --no-default-fulcio --out signing-config-no-fulcio.json
cosign sign-blob --signing-config signing-config-no-fulcio.json --bundle blob.bundle [BLOB_FILE]
# 3. Enforces bundle for blob signing (should fail with "please specify --bundle")
cosign sign-blob [BLOB_FILE]
cosign sign-blob --key cosign.key [BLOB_FILE] |
c675ba9 to
148d48c
Compare
Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
148d48c to
498ff36
Compare
This change enables `UseSignedTimestamps` in `TestSignBlobRFC3161Timestamp` to correctly verify with the signed timestamp. This change also removes redundant trusted root setup code from the test and the redundant helper `prepareTrustedRootTSA`. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
This change removes the trusted root from cases in `TestSignVerifyWithTUFMirror` dedicated to legacy targets and expects `verify-blob` to fail in them. This demonstrates that `verify-blob` does not fall back to legacy targets when verifying a new-format bundle without a trusted root. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
cmurphy
left a comment
There was a problem hiding this comment.
This looks great! This change is really digestible, I appreciate how focused it is. I left a few small suggestions (disclosure: AI helped me find some of these).
This change marks the `--bundle` flag required for `sign-blob`, replacing an `if` statement checking for the bundle path in the command's `PreRunE`. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
This change removes a sentence requiring the `--bundle` flag from the usage strings for the `--use-signing-config` and `--signing-config` flags of `sign-blob`. The sentence is redundant since `--bundle` is always required. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
This change adds to the unit test `TestSignBlobCmd` an assertion that offline, key-based signing produces a bundle containing no certificates, transparency log entries, or RFC 3161 timestamps. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
cmurphy
left a comment
There was a problem hiding this comment.
I left one minor nitpick but I think this is good to merge as-is. Unfortunately it looks like the e2e-registry test is broken and needs an update in scaffolding.
|
I'm working on the scaffolding fix now! |
This change adds to the e2e test `TestSignBlobNewBundle` an assertion that offline, key-based signing produces a bundle containing no certificates, transparency log entries, or RFC 3161 timestamps. Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
Summary
This change mandates the new bundle format for
sign-blob.This disables individual service inputs (i.e., outside of a signing config) and detached outputs.
Release Note
BREAKING CHANGE:
--use-signing-config=falsedisables the use of online services (certificate authorities, transparency logs, or timestamp authorities) for signing.--use-signing-config=falsewithout service configuration flags defaulted to signing with the public-good Fulcio and Rekor instances.--use-signing-config=falseand no service configuration flags succeeds without uploading to a transparency log.Signers requiring services MUST use a signing config (either from TUF via
--use-signing-config[trueby default] or explicitly provided via--signing-config).Signers NOT requiring services MUST set
--use-signing-config=falseor explicitly provide an empty signing config via--signing-config(e.g., created withcosign signing-config create).Several flags have been rendered obsolete:
--rekor-url,--timestamp-server-url,--tlog-upload--use-signing-config=false(to be removed in Remove legacy flags and helpers #5145):--fulcio-url,--oidc-issuer--new-bundle-format--rfc3161-timestamp,--b64,--output/--output-signature/--output-certificate