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

docs: cosign upgrade design document #1246

Merged

Conversation

akashsinghal
Copy link
Collaborator

Description

What this PR does / why we need it:

Overall technical design breakdown of all work proposed to support robust cosign verification support in Ratify. This is an evolving document and PR should be used for discussion.

Focuses on issues in:

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):

Fixes #

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Helm Chart Change (any edit/addition/update that is necessary for changes merged to the main branch)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • Does the affected code have corresponding tests?
  • Are the changes documented, not just with inline documentation, but also with conceptual documentation such as an overview of a new feature, or task-based documentation like a tutorial? Consider if this change should be announced on your project blog.
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have appropriate license header?

Post Merge Requirements

  • MAINTAINERS: manually trigger the "Publish Package" workflow after merging any PR that indicates Helm Chart Change

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (dev@482ac34). Click here to learn what that means.

❗ Current head 69c87dc differs from pull request most recent head 6af9cb5. Consider uploading reports for the commit 6af9cb5 to get more accurate results

Additional details and impacted files
@@          Coverage Diff           @@
##             dev    #1246   +/-   ##
======================================
  Coverage       ?   65.58%           
======================================
  Files          ?      109           
  Lines          ?     5579           
  Branches       ?        0           
======================================
  Hits           ?     3659           
  Misses         ?     1565           
  Partials       ?      355           

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

docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
- Bob attempts to deploy a pod from the vetted image that has 1 cosign signature, which is signed with key in CertificateStore `inline-key-build`. Pod FAILS verification and blocked.
- Bob attempts to deploy a pod from the vetted image that has 2 cosign signatures, which is signed with keys in CertificateStore `inline-key-build` & `inline-key-test`. Pod passes verification and is created.

> **NOTE**: Based on Cosign's own verification implementation, there does not seem to be a way to enforce that ALL signatures found are valid. This behavior is unchartered as far as we can tell and would require Ratify to determine if we want to support this directly. For that reason, the strict ALL signature scenario is not yet included.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel it's a valid case since we already support this scenario in notation verifier. The question is that if we want to have single cosign verifier to enforce it or have different cosign verifiers with different keys.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

very true. we need to discuss this. I will bring this up as topic to discuss

@akashsinghal akashsinghal marked this pull request as ready for review January 18, 2024 19:34
- add new `keys` field to spec
- Multitenancy considerations
- Need a separate keys map for namespaced and global certificate store keys
#### Renaming CertificateStore to KeyManagementSystem
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will renaming CRD be a breaking change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We would have to introduce the new CRD KeyManagementSystem as a new and separate resource and then deprecate the existing one. I think removing full support for it would be breaking change... we should discuss this. The simplest option would be to keep the CertificateStore but the name is the only issue to consider.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the new CRD name KeyManagementSystem narrow to the Key Management System? If users use a managed signing service like AWS Signer or Azure Code Signing service, is this CRD applicable for non-KMS service?

- Image manifest pushed to same repository as subject (tag schema: `sha256-abc123.sig`)
- Image manifest is updated every time new signature is added. Each layer is a different signature (possibly from different signing keys)
```json
# Sample Cosign OCI Image Manifest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Sample Cosign OCI Image Manifest
# Sample OCI Image Manifest with Cosign signanture

- However, if a user decides to do a mixture of cert stores + local directory then they would need to specify in 2 different sections (cosign plugin config + cert store)
- **UPDATE 1/18/24**: We will mirror notation experience with a `verificationKeys` field in the cosign verifier config

## Support Multiple keys for cosign verification
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: make sure our docs for cosign + notation call out capabilities of mulit key + cert by default.


## Support Multiple keys for cosign verification

Currently, there is only support for a single key per cosign verifier.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: open up an issue for revocation key list?

Copy link
Collaborator

Choose a reason for hiding this comment

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

who will own the management of revocation keys? Ratify or third-party service?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For external KMS like akv, I think we rely upon AKV to mark the certs as revoked. This will tie into the work to add periodic certificate refresh from KMS. In that case, if a cert is marked revoked in AKV, then Ratify can remove that cert. For inline scenarios, the user will have to inform Ratify if a certificate is revoked. In this case is a revocation list even necessary? Can't the user just delete the cert reference in the CRD?

Copy link
Collaborator

@yizha1 yizha1 Jan 26, 2024

Choose a reason for hiding this comment

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

I am also working on this if only key pairs (private key + public key) are used, no certificates. What will be the expiry and revocation experience.

To clarify the difference between Cosign and Notary Project. The key for cosign verification, it means public key. For notary project, we use root CA certificate, not public key. It's different. Cosign does support verification using certificates, but it is not in the scope of cosign support yet. I will bring more clarification on this soon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @yizha1 for context. So in public key scenario, if user wants to revoke public key, they would simply just delete the key in their Key Vault? There's no concept of expiry like in certificates?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If users manage key pairs in AKV, and the key is compromised, users need to rotate the key, so there will be a new version of the key. If we always retrieve the latest version of the key, then there should be a way to gracefully remove the previous version of the key. There is no concept of key expire, but AKV allows uses to set expiration date, but after expiration, users need to disable the version of key or delete the key totally, then this should be detectable via API, so the question I think is more about how to gracefully remove the old version of key in what context. We can discuss it further in the community meeting and document the behavior.

- User specifies enforcement type by specifying `count` of verification operations that must succeed.
- e.g 2 keys specified and 2 signatures on the image. each verification is against both signatures for a single key
- If count is 2, then 2 verifications must return true
- Why is `keyEnforcement` necessary?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What about 'scope` field by registry similar to notation's trust policy

Copy link
Collaborator

@binbin-li binbin-li Jan 25, 2024

Choose a reason for hiding this comment

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

do you think if we should introduce a general trust policy to cert/key based verifiers?

Copy link
Collaborator Author

@akashsinghal akashsinghal Jan 25, 2024

Choose a reason for hiding this comment

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

yeah that's a good suggestion. I think from a user standpoint we can try to mirror some of the functionality (trust policy has a lot of useful things for keys too like registryScopes and trustStores) but it also has some fields that are not applicable to keys too like identities and signatureVerification level which are notation specific. I'm concerned that we might start overloading the trust policy schema to mean 2 different things between cosign and notation.

From implementation POV, it might not make sense to unify since we already consume the trust policy doc and pass it directly to notation-go. There's no parsing/processing.

- Multitenancy considerations
- Need a separate keys map for namespaced and global certificate store keys

### Option 2: Renaming CertificateStore to KeyManagementSystem
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fseldow We are planning to deprecate CertificateStore and move to a new resource which will bundle certificate + key management. I'd appreciate your input on this decision as well as any comments you have on the cosign doc.

@akashsinghal akashsinghal self-assigned this Mar 1, 2024
Copy link
Collaborator

@yizha1 yizha1 left a comment

Choose a reason for hiding this comment

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

Thanks Akash, I will create a new doc under the discuss folder for "Cosign scenarios", which will help to understand whether the implementation design can meet the needs.

docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
docs/discussion/Cosign Upgrade 2024.md Outdated Show resolved Hide resolved
@akashsinghal akashsinghal changed the base branch from main to staging April 9, 2024 16:57
Copy link
Collaborator

@susanshi susanshi left a comment

Choose a reason for hiding this comment

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

Looks good to me. thanks for capturing all the discussion history.

@akashsinghal akashsinghal enabled auto-merge (squash) April 24, 2024 18:55
@akashsinghal akashsinghal merged commit 26d7a11 into ratify-project:dev Apr 24, 2024
15 checks passed
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.

6 participants