Open Mukuls77 opened 1 year ago
I have tested the scenario on a cluster now sharing the working and not working logs TestResults.zip
@Mukuls77 I am afraid this behaviour is intentional to ask for any intermediate and the root certificate.
Hi Hector the cosign base code support the flow in which we set the SIGSTORE_ROOT_FILE env variable to rootCert and than in verify command we dont pass any Intermediate cert so than cosign picks the cert chain and cert from the Registry and validate those using the Root cert provided in SIGSTORE_ROOT_FILE. so a similar behaviour should be supported when we are using policy controller also kindly ignore the failed logs traces i shared before today there was a mistake in my policy i am now sharing the correct failed log traces here now NotWorkingLogswithRootCertOnly.zip
@Mukuls77 Alright! I'll have a look at the logs.
@Mukuls77 I've tried using the certChain
containing the SIGSTORE_ROOT_FILE (with only the root certificate), and it worked for me. Are you sure you set the right organization and commonName aligned with your certificate ? I saw the content of the certificate and they don't match the value entered in the trustRoot.
Please, make sure you're using the root certificate only.
Hi Hector thanks for the update. actually i used a new set of certs for generating these logs, and i validated that i am using correct root cert in my test. I am sharing the cert used for this test for your view. printing the values of the cert for quick view
/home/mukul/tarballTest>openssl x509 -text -in rootCA.crt Certificate: Data: Version: 3 (0x2) Serial Number: 54:c0:4b:1e:d7:24:24:10:bd:6d:65:ad:73:a1:01:f9:54:ba:17:2e Signature Algorithm: sha256WithRSAEncryption Issuer: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = CNS, CN = NCD, emailAddress = mukul.sharma@nokia.com Validity Not Before: Apr 25 07:07:07 2023 GMT Not After : Apr 23 07:07:07 2028 GMT Subject: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = CNS, CN = NCD, emailAddress = mukul.sharma@nokia.com
/home/mukul/tarballTest>openssl x509 -text -in intermediateCA.crt Certificate: Data: Version: 3 (0x2) Serial Number: 2e:7c:21:be:8c:21:ca:c6:e0:66:a9:5b:42:ac:f2:9e:21:8b:7a:e5 Signature Algorithm: sha256WithRSAEncryption Issuer: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = CNS, CN = NCD, emailAddress = mukul.sharma@nokia.com Validity Not Before: Apr 25 09:32:37 2023 GMT Not After : Apr 23 09:32:37 2028 GMT Subject: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = CNS, CN = NCD, emailAddress = mukul.sharma@nokia.com
/home/mukul/tarballTest>openssl x509 -text -in leafCA.crt Certificate: Data: Version: 3 (0x2) Serial Number: 06:35:d1:dc:1f:fe:0d:17:1d:38:b4:e7:ad:25:40:08:6b:48:bc:71 Signature Algorithm: sha256WithRSAEncryption Issuer: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = CNS, CN = NCD, emailAddress = mukul.sharma@nokia.com Validity Not Before: Apr 25 09:34:06 2023 GMT Not After : Apr 23 09:34:06 2028 GMT Subject: C = IN, ST = DELHI, L = DELHI, O = NOKIA, OU = NCD, CN = NCD, emailAddress = mukul.sharma@nokia.com
also when i use Intemediate cert + root cert in the cert chain than the policy controller works fine. it only fails when i am using only root cert.
logs attached for working case
Hi Hector i tried the policy validation again with a different set of leaf, intermediate and root cert but the result is the same if it only use root cert in the Trustroot than validation fails but it works if i use Intermediate cert + root cert in the trust root. as you mentioned it worked for you can you pls share the certs you used for your case (leaf, intermediate, root) so that i can check what is the difference in my case.
@hectorj2f can you pls provide the certs (leaf , intermediate, root) and the leaf key so that i can check this case, as i tried it myself using my certs and cert chain but it is not working till i provide complete cert chain (intermediate + root) in the trust root. It only work for me when i have only leaf and root cert as the complete chain i.e. no intermediate cert is present, as i use an intermediate cert than just setting root cert in trust root does not work. But as i explained before the same scenario works with cosign when i just set SIGSTORE_ROOT_FILE to root cert.
Support keyless Signature verification using only Root certificate
Use case Description:
Issue Description currently cosign support verification of the signature using just root certificate using following mechanism.
We have an artifact which has associated signature, cert and cert chain in the registry.
showing the manifest of the signature for refrence.
Artifact : ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9 Fetching signature: ./cosign-linux-amd64 triangulate ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9 ttl.sh/cosign-ci/68ab7a70:sha256-ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9.sig
Signature manifest
crane manifest ttl.sh/cosign-ci/68ab7a70:sqa256-ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9.sig |j { "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "config": { "mediaType": "application/vnd.oci.image.config.v1+json", "size": 357, "digest": "sha256:da8a1a9eb14cf44984c1daba0400ae5047ed3cae705266594597116d8738fc91" }, "layers": [ { "mediaType": "application/vnd.dev.cosign.simplesigning.v1+json", "size": 241, "digest": "sha256:3c2165afcc2d11083dcc469440ca74b8bffa0fdd6c8818ed06933f3c839533c1", "annotations": { "dev.cosignproject.cosign/signature": "MEYCIQDiD1Ba6QvsNu6R1uMi3f/Kw7UqcIWejVyJxFv1mTDFeQIhAIzeMcZYPFd9J5cuEdiGqfGb0CY6mH0IBRyKvBpwKBuQ" } }, { "mediaType": "application/vnd.dev.cosign.simplesigning.v1+json", "size": 242, "digest": "sha256:61b4e7ee03e7df79b6c8182e8440b4b794300aabb9f25b29d818e9aa595fa2ff", "annotations": { "dev.cosignproject.cosign/signature": "DLDjxmPo5pJOaoX3+EPzMBGMQ85iaKadAdCIPVh80fidXy8cf194JT0/J3dbS1isxmFEPNolpdsU\nZtJ1Nsq1zM5biyM6iwyEZre07nAkvxrhrr+33BGI4p8Iq8snfyF/Dn9kkntxpAgXfQbtg2M0GMcv\n8hO7Vq7rlX2ZJTqfPgyfxIoobIml1wfA5MksiYbzxryCKG/p1Da9rytJPA36QbLsZEK/pjVH993m\ny3pylEDqkqi2kbNQFMZr9Pc3Blx1UiRP+8qDlmI+D1g+Qf0xo8VUTGgcsWZQBuIBXa35RakbA5Ib\nXurzHWU0nnk0IFdicUlaORIrKr/7SeIjC6mcew==\n", "dev.sigstore.cosign/certificate": "-----BEGIN CERTIFIC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lCkZrWhai33+A\nFuOC9rk2pAYN49IXN7EpNhgIvCp4O0A=\n-----END CERTIFICATE-----\n" } } ] }
Verify using cosign verify command
echo $SIGSTORE_ROOT_FILE /home/mukul/policy-controller/mypolicy/rootCA.crt /home/mukul/policy-controller/mypolicy>./cosign-linux-amd64 verify ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9 --insecure-ignore-sct --insecure-ignore-tlog --certificate-identity-regexp '.' --certificate-oidc-issuer-regexp '.' Warning Skipping tlog verification is an insecure practice that lacks of transparency and auditability verification for the signature.
Verification for ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9 -- The following checks were performed on each of these signatures:
[{"critical":{"identity":{"docker-reference":"ttl.sh/cosign-ci/68ab7a70"},"image":{"docker-manifest-digest":"sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9"},"type":"cosign container image signature"},"optional":{"Subject":""}}]
Verification using policy tester To verify the policy for this scenario i used the policy Tester. Created following policies Policy File: cip-my-keyless.yaml apiVersion: policy.sigstore.dev/v1alpha1 kind: ClusterImagePolicy metadata: name: demo spec: images:
Trust Root: file my-sigstore-keys.yaml
apiVersion: policy.sigstore.dev/v1alpha1 kind: TrustRoot metadata: name: my-sigstore-keys spec: sigstoreKeys: certificateAuthorities:
Testing using policy tester When i test this policy and trust root it fails
/home/mukul/policy-controller/mypolicy>./policy-tester -image ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9 -policy cip-my-keyless.yaml -trustroot my-sigstore-keys.yaml 2023-04-07T12:01:05.933+0530 DEBUG webhook/validator.go:497 Checking Authority: authority-0 2023-04-07T12:01:10.896+0530 ERROR webhook/validator.go:763 failed validSignatures for authority authority-0 with fulcio for ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9: no matching signatures: no certificate found on signature cert verification failed: x509: certificate signed by unknown authority. Check your TUF root (see cosign initialize) or set a custom root with env var SIGSTORE_ROOT_FILE github.com/sigstore/policy-controller/pkg/webhook.ValidatePolicySignaturesForAuthority github.com/sigstore/policy-controller/pkg/webhook/validator.go:763 github.com/sigstore/policy-controller/pkg/webhook.ValidatePolicy.func1 github.com/sigstore/policy-controller/pkg/webhook/validator.go:529 {"errors":["signature keyless validation failed for authority authority-0 for ttl.sh/cosign-ci/68ab7a70@sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9: no matching signatures:\nno certificate found on signature\n cert verification failed: x509: certificate signed by unknown authority. Check your TUF root (see cosign initialize) or set a custom root with env var SIGSTORE_ROOT_FILE: "]}
It works only when i use the complete cert chain i.e. (Intermediate cert + Root Cert) in the argument
Impact and benefit of this issue currently as i notice policy controller only support passing complete cert chain in the argument to validate the signature. This will have impact on usability in the case where an organization generates separate Intermediate Certs for its departments, so in such case the policy logic will become complex
This can be made simple if we allow only Root cert to be used for verification as is allowed in cosign tool. In that case we will just need a single Trust Root and can use that trust root in all the policies.