-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix verification of signatures produced with pki11 #142
fix verification of signatures produced with pki11 #142
Conversation
The documentation of the `SignatureLayer::new` method was mentioning a parameter that no longer exists. Signed-off-by: Flavio Castelli <fcastelli@suse.com>
The `cosign` tool can produce signatures using a PKCS11 token. These signatures feature a `certificate` annotation inside of their OCI layer. However, when `COSIGN_EXPERIMENTAL` is not enabled, the layer will not feature a Rekor bundle. Prior to this commit, the code assumed signature layers could have a `certificate` annotation only when using the Fulcio integration. Because of that, layers with a `certificate` but without a Rekor bundle were discarded. That was done to ensure the robustness of keyless verification. This commit changes the code that creates `SignatureLayer` objects to not raise errors when an embedded certificate cannot be verified. Be it because it has been forged/invalid/etc or because the Rekor bundle is not found inside of the layer. The resulting `SignatureLayer` will not be discarded, but it will have its `certificate_signature` attribute set to `None`. > **Note:** `SignatureLayer::certificate_signature` was already a `Option` > before of this commit. The verification constraints implementing keyless verification will discard these kind of layers because they do not have a `certificate_signature`. However, the public key based verifier will be able to verify the signature stored inside of the layer. This solves the following scenario: > Given Alice signed a container image using a PKCS11 token but without having cosign's Rekor integration enabled > When verifying the container image signature using the public key associated with the certificate stored on her PKCS11 token > Then the container image will be reported as successfully verified Fixes sigstore#135 Signed-off-by: Flavio Castelli <fcastelli@suse.com>
523650e
to
5b1fae7
Compare
Address clippy and rustfmt warnings Signed-off-by: Flavio Castelli <fcastelli@suse.com>
b337376
to
51fcde8
Compare
SigstoreError::SigstoreFulcioCertificatesNotProvidedError | ||
)); | ||
); | ||
assert!(cert.is_none()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test functions should be renamed now, e.g:
get_certificate_signature_from_annotations_fails_when_no_bundle_is_given()
get_certificate_signature_from_annotations_fails_when_no_fulcio_pub_key_is_given()
should be renamed to [...]_returns_none()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! just a minor nit.
I like this approach. This PR fix #135 by not failing if the certificate in the |
Fixes ===== * fix verification of signatures produced with PKI11 (sigstore#142) Others ====== * Update rsa dependency to stable version 0.7.0 (sigstore#141) * Bump actions/checkout from 3.0.2 to 3.1.0 (sigstore#140) Contributors ============ * Flavio Castelli (@flavio) * Xynnn (@Xynnn007) Signed-off-by: Flavio Castelli <fcastelli@suse.com>
The
cosign
tool can produce signatures using a PKCS11 token. These signatures feature acertificate
annotation inside of their OCI layer.However, when
COSIGN_EXPERIMENTAL
is not enabled, the layer will not feature a Rekor bundle.Prior to this commit, the code assumed signature layers could have a
certificate
annotation only when using the Fulcio integration. Because of that, layers with acertificate
but without a Rekor bundle were discarded. That was done to ensure the robustness of keyless verification.This commit changes the code that creates
SignatureLayer
objects to not raise errors when an embedded certificate cannot be verified. Be it because it has been forged/invalid/etc or because the Rekor bundle is not found inside of the layer.The resulting
SignatureLayer
will not be discarded, but it will have itscertificate_signature
attribute set toNone
.The verification constraints implementing keyless verification will discard these kind of layers because they do not have a
certificate_signature
.However, the public key based verifier will be able to verify the signature stored inside of the layer.
This solves the following scenario:
Fixes #135