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

support verification of the signature with multiple public keys #950

Open
developer-guy opened this issue Oct 25, 2021 · 21 comments
Open

support verification of the signature with multiple public keys #950

developer-guy opened this issue Oct 25, 2021 · 21 comments
Labels
enhancement New feature or request

Comments

@developer-guy
Copy link
Member

developer-guy commented Oct 25, 2021

Description

The idea is actually came from here1. We can support verification of the signature with multiple public keys, I couldn't think over the design much yet but, at the end of the day it might look like the following:

$ cosign verify --key awskms:///1234abcd-12ab-34cd-56ef-1234567890ab --key hashivault://testkey --key k8s://default/mysecret  <IMAGE>

cc: @Dentrax @dlorenc @JimBugwadia @hectorj2f

Footnotes

  1. https://github.com/kyverno/kyverno/issues/2583

@developer-guy developer-guy added the enhancement New feature or request label Oct 25, 2021
@hectorj2f
Copy link
Contributor

Yes, this scenario makes sense and we are planning to donate that implementation to cosigned.

@hectorj2f
Copy link
Contributor

As briefly detailed here #594 (comment), it will support multiple keys.

@hectorj2f
Copy link
Contributor

Regarding AND or OR question, we are today following an OR approach. However I am more inclined towards an AND that follows an airport security checking approach.

@developer-guy
Copy link
Member Author

So, can we start working on the implementation of it with an AND approach, or what are the other concerns should we consider first?

@hectorj2f
Copy link
Contributor

I'd like to hear @dlorenc thoughts about which approach would fit better.

@dlorenc
Copy link
Member

dlorenc commented Oct 26, 2021

I think either one is fine, it worries me that it might not actually be clear though :(

AND is safer since it would "fail closed".

@dlorenc
Copy link
Member

dlorenc commented Oct 26, 2021

I wonder if it would make sense to move this up to the policy level rather than in flags.

What if you could pass in a simple cue file with public keys, that could contain more complex and/or logic:

  • These two keys, or that one
  • 3 out of these 5

etc.

@dlorenc
Copy link
Member

dlorenc commented Oct 26, 2021

Also: I think there are at least three places we can handle this (maybe differently!):

  • Cosigned (support for OR makes sense here because of rotation)
  • the CLI
  • the libraries

@adamd-vmw
Copy link

AND is safer but OR is a valid use case.

"admit the pod if the image was signed by this system/team or that system/team or this vendor" etc.

probably more common than the AND use case.

my position is that the user should have the choice to configure AND or OR, or 3 of 5, or at least 2, or whatever.

@stormqueen1990
Copy link

stormqueen1990 commented Oct 26, 2021

For the CLI, would it be fair to have flags specifying the policy (i.e., --policy-type any-of/all-of) and a threshold number (i.e., --threshold 1)?

@dlorenc
Copy link
Member

dlorenc commented Oct 26, 2021

AND is safer but OR is a valid use case.

Yep... in the CLI where it's implicit I'd feel safer with AND. I'd rather figure out a way to be explicit about it though.

@houdini91
Copy link
Contributor

houdini91 commented Oct 27, 2021

Just asking out of curiosity, sorry if i am off topic.
Wouldn't doing something similar for attestations make also sense ? (maybe using envelope and dsse signers that support multi signer flow)

@dlorenc
Copy link
Member

dlorenc commented Oct 29, 2021

Wouldn't doing something similar for attestations make also sense ? (maybe using envelope and dsse signers that support multi signer flow)

Yes probably!

I wrote this up with some other ideas on custom polices: https://gist.github.com/dlorenc/a9681f6c0ed08a7710ba52a7f76887f6

I'd love some early feedback!

@JimBugwadia
Copy link
Contributor

Currently cosign.VerifySignatures takes a signature.Verifier and loops through all signatures and invokes the verifier. Can this be refactored to push multiple signatures to a new abstraction that performs the logic to verify the entire set against policies or other declarations?

Something like this:

type Verifier interface {
	 VerifySignatures(signatures []oci.Signature, opts ...signature.VerifyOption) error
}

type MultiKeyVerifier struct {
	// the number of verifiers that must be applied (defaults to 1)
	// - all: min = len(verifiers)
	// - any: min = 1
	// - count (e.g. 2/5): min = count
	min int
	// the list of keys to attempt
	verifiers []Verifier
}

func (mv *MultiKeyVerifier) VerifySignatures(signatures []oci.Signature, opts ...signature.VerifyOption) error {
	// todo - verify signatures based on signature sets
	return nil
}

type CueVerifier struct {
  // todo - declare or construct a Cue policy
}

func (mv *CueVerifier ) VerifySignatures(signatures []oci.Signature, opts ...signature.VerifyOption) error {
	// todo - verify signatures based on Cue policy
        return nil
}

We can then support different verifiers e.g. CueVerifier, MultiKeyVerifier, SingleKeyVerifier, etc. that perform the necessary checks and pass or fail the entire signature set or attestation set.

@Dentrax
Copy link
Member

Dentrax commented Nov 16, 2021

Kind ping here 🙏

@houdini91
Copy link
Contributor

Issue/PR may be relevant.
https://github.com/secure-systems-lab/go-securesystemslib/issues/4
secure-systems-lab/go-securesystemslib#7

@JimBugwadia
Copy link
Contributor

Hi @houdini91 @Dentrax - is the plan to use the MultiEnvelopeSigner in cosign.VerifySignatures?

@developer-guy
Copy link
Member Author

Hi @JimBugwadia, IMHO, there are things that we have to decide what we should do first like:

  • Should it be evaluated AND or OR when we define multiple keys?

  • Should we define a threshold number to make it valid check for defining at least N keys should be evaluated as true?

am I right @dlorenc @hectorj2f ?

@hectorj2f
Copy link
Contributor

hectorj2f commented Nov 19, 2021

Yes, you are right in my opinion.

Should it be evaluated AND or OR when we define multiple keys?

For our use cases, we need to answer this question ☝🏻 which is more important at this moment. It should be configurable because it sounds like a realistic situation at many customers.

Should we define a threshold number to make it valid check for defining at least N keys should be evaluated as true?

I am not sure this is necessary if we decide on using cue to define the AND/OR policy for the keys, as proposed from @dlorenc .

@houdini91
Copy link
Contributor

houdini91 commented Nov 22, 2021

@JimBugwadia

Hi @houdini91 @Dentrax - is the plan to use the MultiEnvelopeSigner in cosign.VerifySignatures?

I am down with what ever the community leader think is best.
My own view of the support is as following

  1. Add DSSE multi sign/verify support as specified by spec DSSE Multi sign spec
    PR is in progress 7
  2. Add support to sigstore code base using the MultiEnvelopeSigner and MultiEnvelopeVerifier
  3. Hopefully until this time there will be better answers how cosign multi sign verifying process.
    I am guessing cosign may decide it wants to pass the verified key list via policy or other logic as well as threshold or maybe they will decide to always use signal envelope signer witch are simply multi signers/verifiers with a default threshold of 1.
    In any way the basic building block will be (1) and (2).
  • In my opinion Threshold is just a bonus verification option i added it to the PR because it is part of the DSSE spec.
  • Multi sign/verify support should return ALL the accepted keys no matter the threshold value or envelope type.

@ls250412
Copy link

We have a use case for the OR multiple public keys. On testing we can see only AND support currently, has the support for OR based multi-keys stalled over the last 2 years or has it been taken elsewhere?

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

9 participants