Skip to content
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

[Enhancement] Document the verification of attestations produced from private GitHub repositories #1435

Open
EtienneDufresne opened this issue Nov 12, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@EtienneDufresne
Copy link

EtienneDufresne commented Nov 12, 2024

Description

The verifying sigstore bundles section of the documentation is specific to public GitHub repositories where the official Sigstore instance is used.

If the attestation is produced from a private GitHub repo (and for a private artifact), the GitHub Sigstore instance is used and there are no transparency logs as stated here.

For kyverno to be able to verify such attestations, its helm values.yaml must have this override:

features:
  tuf:
    enabled: true
    mirror: https://tuf-repo.github.com
    rootRaw: <set to https://github.com/github/artifact-attestations-helm-charts/blob/main/charts/trust-policies/templates/trustroot-github.yaml#L8-L9>

In the ClusterPolicy, the attestation keyless attestor entry's rekor value must be updated to point to the GitHub Signstore Fulcio instance and set to ignore the transparency logs:

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  annotations:
    pod-policies.kyverno.io/autogen-controllers: none
  name: sigstore-attestation-verification
spec:
  background: false
  validationFailureAction: Enforce
  webhookTimeoutSeconds: 30
  rules:
  - match:
      any:
      - resources:
          kinds:
          - Pod
    name: sigstore-attestation-verification
    verifyImages:
    - imageReferences:
      - "*"
      type: SigstoreBundle
      attestations:
      - attestors:
        - entries:
          - keyless:
              issuer: https://token.actions.githubusercontent.com
              subject: https://github.com/vishal-chdhry/artifact-attestation-example/.github/workflows/build-attested-image.yaml@refs/heads/main
              rekor:
                ignoreTlog: true
                url: https://fulcio.githubapp.com
        conditions:
        - all:
          - key: '{{ buildDefinition.buildType }}'
            operator: Equals
            value: https://actions.github.io/buildtypes/workflow/v1
        type: https://slsa.dev/provenance/v1

Slack discussion

https://kubernetes.slack.com/archives/CLGR9BJU9/p1720769654925739

@EtienneDufresne EtienneDufresne added the enhancement New feature or request label Nov 12, 2024
Copy link

welcome bot commented Nov 12, 2024

Thanks for opening your first issue here! Be sure to follow the issue template!

@julien-michaud
Copy link

@EtienneDufresne are you able to successfully verify your attestations with the conf you provided ?

getting a weird sigstore bundle verification failed: no matching signatures found

{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","key":"kyverno.io/verify-images","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T15:58:00Z","message":"missing image metadata in annotation"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","namespace":"devex-776-jmichaud","policy":"sigstore-attestation-verification","ruleName":"sigstore-attestation-verification","imageRef":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T15:58:00Z","message":"cache entry not found"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","attestors":0,"attestations":1,"time":"2024-12-05T15:58:00Z","message":"verifying image signatures"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","time":"2024-12-05T15:58:00Z","message":"attestation {Name: PredicateType: Type:https://slsa.dev/provenance/v1 Attestors:[{Count:<nil> Entries:[{Keys:<nil> Certificates:<nil> Keyless:0xc0002d1030 Attestor:nil Annotations:map[] Repository: SignatureAlgorithm:sha256}]}] Conditions:[{AnyConditions:[] AllConditions:[{RawKey:&JSON{Raw:*[34 123 123 32 98 117 105 108 100 68 101 102 105 110 105 116 105 111 110 46 98 117 105 108 100 84 121 112 101 32 125 125 34],} Operator:Equals RawValue:&JSON{Raw:*[34 104 116 116 112 115 58 47 47 97 99 116 105 111 110 115 46 103 105 116 104 117 98 46 105 111 47 98 117 105 108 100 116 121 112 101 115 47 119 111 114 107 102 108 111 119 47 118 49 34],} Message:}]}]}"}
{"level":"error","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","error":"sigstore bundle verification failed: no matching signatures found","logger":"engine.verify","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T15:58:00Z","message":"failed to fetch attestations"}
{"level":"trace","gvk":"/v1, Kind=Pod","gvr":{"group":"","version":"v1","resource":"pods"},"namespace":"devex-776-jmichaud","name":"julienm","operation":"CREATE","uid":"9042883d-7dc7-4108-8759-1cedf1857f7d","user":{"username":"julien.michaud","groups":["team-labs","teleport-sre","system:authenticated"]},"roles":[],"clusterroles":["cluster-admin","company-list-all-ns","system:basic-user","system:discovery","system:public-info-viewer","view"],"resource.gvk":"/v1, Kind=Pod","kind":"Pod","URLParams":"","v":2,"logger":"webhooks/resource/mutate","policy":"sigstore-attestation-verification","time":"2024-12-05T15:58:00Z","message":"blocking admission request"}
{"level":"error","gvk":"/v1, Kind=Pod","gvr":{"group":"","version":"v1","resource":"pods"},"namespace":"devex-776-jmichaud","name":"julienm","operation":"CREATE","uid":"9042883d-7dc7-4108-8759-1cedf1857f7d","user":{"username":"julien.michaud","groups":["team-labs","teleport-sre","system:authenticated"]},"roles":[],"clusterroles":["cluster-admin","company-list-all-ns","system:basic-user","system:discovery","system:public-info-viewer","view"],"resource.gvk":"/v1, Kind=Pod","kind":"Pod","URLParams":"","error":"\n\nresource Pod/devex-776-jmichaud/julienm was blocked due to the following policies \n\nsigstore-attestation-verification:\n  sigstore-attestation-verification: 'image attestations verification failed, verifiedCount:\n    0, requiredCount: 1, error: sigstore bundle verification failed: no matching signatures\n    found'\n","logger":"webhooks/resource/mutate","time":"2024-12-05T15:58:00Z","message":"image verification failed"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","key":"kyverno.io/verify-images","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T16:12:11Z","message":"missing image metadata in annotation"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","namespace":"devex-776-jmichaud","policy":"sigstore-attestation-verification","ruleName":"sigstore-attestation-verification","imageRef":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T16:12:11Z","message":"cache entry not found"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","attestors":0,"attestations":1,"time":"2024-12-05T16:12:11Z","message":"verifying image signatures"}
{"level":"trace","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","v":2,"logger":"engine.verify","time":"2024-12-05T16:12:11Z","message":"attestation {Name: PredicateType: Type:https://slsa.dev/provenance/v1 Attestors:[{Count:<nil> Entries:[{Keys:<nil> Certificates:<nil> Keyless:0xc00147ce00 Attestor:nil Annotations:map[] Repository: SignatureAlgorithm:sha256}]}] Conditions:[{AnyConditions:[] AllConditions:[{RawKey:&JSON{Raw:*[34 123 123 32 98 117 105 108 100 68 101 102 105 110 105 116 105 111 110 46 98 117 105 108 100 84 121 112 101 32 125 125 34],} Operator:Equals RawValue:&JSON{Raw:*[34 104 116 116 112 115 58 47 47 97 99 116 105 111 110 115 46 103 105 116 104 117 98 46 105 111 47 98 117 105 108 100 116 121 112 101 115 47 119 111 114 107 102 108 111 119 47 118 49 34],} Message:}]}]}"}
{"level":"error","policy.name":"sigstore-attestation-verification","policy.namespace":"devex-776-jmichaud","policy.apply":"All","new.kind":"Pod","new.namespace":"devex-776-jmichaud","new.name":"julienm","rule.name":"sigstore-attestation-verification","error":"sigstore bundle verification failed: no matching signatures found","logger":"engine.verify","image":"europe-docker.pkg.dev/foo/company-prod/devex/julienm:sha256-150fd47a8ad987b565fc5b995e1ace789c4132c98a09eb919bec8960e3fa8a72","time":"2024-12-05T16:12:12Z","message":"failed to fetch attestations"}
{"level":"trace","gvk":"/v1, Kind=Pod","gvr":{"group":"","version":"v1","resource":"pods"},"namespace":"devex-776-jmichaud","name":"julienm","operation":"CREATE","uid":"9372f8a1-2280-4376-95c3-3485b3b94eb5","user":{"username":"julien.michaud","groups":["team-labs","teleport-sre","system:authenticated"]},"roles":[],"clusterroles":["cluster-admin","company-list-all-ns","system:basic-user","system:discovery","system:public-info-viewer","view"],"resource.gvk":"/v1, Kind=Pod","kind":"Pod","URLParams":"","v":2,"logger":"webhooks/resource/mutate","policy":"sigstore-attestation-verification","time":"2024-12-05T16:12:12Z","message":"blocking admission request"}
{"level":"error","gvk":"/v1, Kind=Pod","gvr":{"group":"","version":"v1","resource":"pods"},"namespace":"devex-776-jmichaud","name":"julienm","operation":"CREATE","uid":"9372f8a1-2280-4376-95c3-3485b3b94eb5","user":{"username":"julien.michaud","groups":["team-labs","teleport-sre","system:authenticated"]},"roles":[],"clusterroles":["cluster-admin","company-list-all-ns","system:basic-user","system:discovery","system:public-info-viewer","view"],"resource.gvk":"/v1, Kind=Pod","kind":"Pod","URLParams":"","error":"\n\nresource Pod/devex-776-jmichaud/julienm was blocked due to the following policies \n\nsigstore-attestation-verification:\n  sigstore-attestation-verification: 'image attestations verification failed, verifiedCount:\n    0, requiredCount: 1, error: sigstore bundle verification failed: no matching signatures\n    found'\n","logger":"webhooks/resource/mutate","time":"2024-12-05T16:12:12Z","message":"image verification failed"} 

@EtienneDufresne
Copy link
Author

@julien-michaud yes I was able to verify GH private repo produced attestations with this policy. Maybe @vishal-chdhry would be able to help? I suggest pinging him on slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants