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

falcoctl cosign signature verification #174

Closed
Tracked by #132
maxgio92 opened this issue Oct 25, 2022 · 21 comments · Fixed by #305
Closed
Tracked by #132

falcoctl cosign signature verification #174

maxgio92 opened this issue Oct 25, 2022 · 21 comments · Fixed by #305

Comments

@maxgio92
Copy link
Member

maxgio92 commented Oct 25, 2022

This issue tracks the feature proposal as for #132 to provide commands to:

  • sign
  • verify

in order to guarantee the authenticity and integrity of the Falco artifacts distributed by falcoctl.

Proposal

As falcoctl followed a design where OCI registries are used as storage, for general OCI artifacts, it can make sense to store every artifact, signatures included, as OCI artifacts in registry.

Additional context

@maxgio92 maxgio92 mentioned this issue Oct 25, 2022
11 tasks
@maxgio92 maxgio92 changed the title Implementation of a mechanism to sign/verify integrity and authenticity of artifacts. We may want to use provenance files like Helm. This needs further research. Implementation of a mechanism to sign/verify integrity and authenticity of artifacts Oct 25, 2022
@poiana poiana removed the needs-kind label Oct 25, 2022
@maxgio92 maxgio92 changed the title Implementation of a mechanism to sign/verify integrity and authenticity of artifacts falcoctl sign/verify commands Oct 25, 2022
@maxgio92
Copy link
Member Author

maxgio92 commented Oct 25, 2022

Hi @falcosecurity/falcoctl-maintainers I've some points in mind and related questions:

  • Compatibility: do we want to provide compatibility with current supply chain security tools (e.g. cosign)? Do we want instead to provide compatibility with only falcoctl verify feature? (either implicit or exposed via explicit command)

  • Storage specification: do we want to stick to ORAS artifact? Do we want instead to leverage OCI artifact? (more here (of which manifest) and here)

@maxgio92
Copy link
Member Author

maxgio92 commented Oct 30, 2022

Update: there's work in progress from ORAS and OCI to unify the artifact specs (OCI and ORAS) and consequent support from ORAS - of Go library and cli have already release candidates.

Sources:

@FeynmanZhou
Copy link

FeynmanZhou commented Oct 30, 2022

@maxgio92 I like this proposal and I believe the next release of ORAS CLI and library could be the appropriate solution to support falcoctl sign/verify commands. The reason is that we are also working on similar things in Notary v2 (Notation) for signing and verifying OCI artifacts. Currently, Notation is using ORAS-go. The signatures are also persisted as ORAS artifact manifest.

@FeynmanZhou
Copy link

FeynmanZhou commented Oct 31, 2022

@maxgio92 BTW, Notation-go provides APIs for signing and verifying OCI artifacts. Currently, notation-go is also towards a more extensible framework for easy integration, and we are preparing for the API doc.
Maybe you can investigate if Falcoctl CLI can leverage the Notation API (Notation-go library) in the sign/verify commands. Let me know if you have any questions. Thanks.

@loresuso
Copy link
Member

loresuso commented Oct 31, 2022

Hello there, and thank you for this discussion!
I am taking a deeper look at notation-go. It seems to me that it really could be the way to go!
I'll let you know once I will have a stronger opinion or further questions!

@FeynmanZhou
Copy link

Hello there, and thank you for this discussion! I am taking a deeper look at notation-go. It seems to me that it really could be the way to go! I'll let you know once I will have a stronger opinion or further questions!

Thank you.

@leogr
Copy link
Member

leogr commented Nov 2, 2022

cc @cpanato

@maxgio92
Copy link
Member Author

maxgio92 commented Nov 2, 2022

Thank you so much @FeynmanZhou!

@loresuso
Copy link
Member

loresuso commented Nov 3, 2022

Ok, my two cents on this. I know that for @FeynmanZhou this could be obvious, but I am new to these topics so I will write quite a bit, just to have a validation of what I have understood and find the right way to solve the problem.

We are in front of some alternatives, so let's start from the first one.

The first option we have is to put the signature inside one of the layers of the manifest. I believe that Helm did something similar in the past. I think we all agree that this approach is not optimal, since the signature is not part of the artifact and we may want to have a way to extend the artifact even after we pushed it (classic examples, SBOMs or scan results) and without modifying the digest, so this is the reason why I would not use this approach.

The second approach is cosign. Basically, cosign solves the problem of introducing the signature by creating a new artifact that is tagged with the hash of the artifact it is referring to plus the .sig suffix, as described here. For sure, this works, but to me it sounds a bit like a hack. We are free to do whatever we wants with tags, but I don't think they were meant to establish links between artifacts, and this is why I don't like this approach. Furthermore, the artifact info command of falcoctl will be polluted with all the signatures, and we have to write some more hacky code to filter them out.

Things get really better with notation-go and oras, especially in its latest rc-4 version. Basically, using the subject field of the artifact manifest, we are able to create links between artifact at the manifest level, without introducing weird tags to solve the problem. For who doesn't know, this is how notation store a signature referring to an image:

{
  "mediaType": "application/vnd.cncf.oras.artifact.manifest.v1+json",
  "artifactType": "application/vnd.cncf.notary.v2.signature",
  "blobs": [
    {
      "mediaType": "application/jose+json",
      "digest": "sha256:ec0ac89dde1eba1f73af138ca4819b5a28b7d36c99426d495f33e0a2328c8953",
      "size": 2117
    }
  ],
  "subject": {
    "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
    "digest": "sha256:d7eef7bbe23819225992666a81cd6134f5f80a490c9b78e435b94bd2ba968a4f",
    "size": 942
  },
  "annotations": {
    "io.cncf.oras.artifact.created": "2022-10-31T14:27:16Z"
  }
}

Plus, when the registry will be capable, the Referrers API can be used, that can enable us to discover and get a list of all the artifacts that points to a given one, so that the signature can be retrieved and verified. This for sure is the cleanest way to solve the problem (thank you ORAS authors for doing so!).

Now the problem is that our registry (GHCR in this case), does not yet implement the Referrers API as far as I know. So two questions:

  • Do you know if it can be enabled somewhere, or is it really not implemented for the moment?
  • if it's not implemented, how long do you think it will take to have the feature shipped? do you have some contacts with the people working on GHCR?

By the way, I have seen that we can also take advantage of oras-go v2.0.0-rc.4. One thing that I really like is that we can already start implementing this because that version of oras-go fallbacks to tag-based approach similar to what cosign was doing to link the signature to the artifact. Can you guys elaborate more on how we can do the transition from the tag-based approach to the subject + referrers approach? We will need to delete the image index containing all the manifests that are pointing the reference artifact, and I am a little bit concerned about this because from my experiments it seems that GitHub does not implement the delete API.

Lastly, it would be really nice to see a bump to oras-go v2.0.0-rc.4 in notation-go, just to try this out and see it in action before implementing it in falcoctl!

Hope the conclusions I made are right and that you can answer my questions, thanks!

@FeynmanZhou
Copy link

FeynmanZhou commented Nov 3, 2022

@leogr
You digged into Notation and ORAS deeply and your feedback is also valuable to us. I think we are on the same page.
Let me list your questions below and follow up:

Do you know if it can be enabled somewhere, or is it really not implemented for the moment?

As I know, the OCI Distribution-spec just cut the v1.1.0-rc1 in Sep. I am not sure if GHCR will adopt the rc.1 now.

if it's not implemented, how long do you think it will take to have the feature shipped? do you have some contacts with the people working on GHCR?

I can ask my colleagues to confirm.

Can you guys elaborate more on how we can do the transition from the tag-based approach to the subject + referrers approach?

@shizhMSFT @Wwwsylvia @qweeah Could you pls help to confirm if this transition is already supported by ORAS-go v2.0.0-rc.4?

Last, it would be really nice to see a bump to oras-go v2.0.0-rc.4 in notation-go.

Yes, we are toward the same goal! It was planned in notation-go and hopefully it will bump in Nov. See notaryproject/notation-go#136

cc @sajayantony @SteveLasker @toddysm

@toddysm
Copy link

toddysm commented Nov 3, 2022

I am trying to get a timeline from GHCR for when they will be able to support OCI 1.1 spec. Will update you if I learn something soon.

@shizhMSFT
Copy link

Can you guys elaborate more on how we can do the transition from the tag-based approach to the subject + referrers approach?

@shizhMSFT @Wwwsylvia @qweeah Could you pls help to confirm if this transition is already supported by ORAS-go v2.0.0-rc.4?

According to the upgrade procedures of the distribution-spec, the remote registry may do the transition at the server side. In the case of the remote server not doing the transition, the transition still can be done at the client side using oras-go v2.0.0-rc.4 or above.

@maxgio92
Copy link
Member Author

maxgio92 commented Nov 4, 2022

Thanks @shizhMSFT @toddysm @FeynmanZhou @loresuso !!!

I think individual implementations of generic artifacts (signatures, SBOM, attestation, etc.) storage have been around before the introduction of what then OCI and ORAS communities just contributed and worked to unify into OCI as standard (artifact spec and reference API to link artifacts).

Now that registries are working too to stick to the fresh specification (e.g. Docker Hub) I believe - also becasue falcoctl is (re)fresh too - can make sense to follow OCI through the notation library. My 2 cents

@maxgio92
Copy link
Member Author

maxgio92 commented Nov 4, 2022

An important point: do we want to include both the signin and verification features inside falcoctl?

Or, do we want to include verification only and instead delegate signin to external tools (e.g. supposed to run in CI alongside a falcoctl artifact push)?

In both cases, a decision on the API is needed IMO.

Moreover, as notaryproject/notation-go#136 will be completed I'd like to work on this and then propose it in draft if you agree.

@SteveLasker
Copy link

hi @maxgio92, you hit the primary point that we’re working towards; implementing standards (cose for singing), so any project, product or service can implement signing or verification across those standards.

@leogr
Copy link
Member

leogr commented Nov 8, 2022

Hey folks,

I've read this interesting discussion and some random thoughts came to my mind:

  • IMO, users should be free to sign things using their preferred tool,
  • so falcoctl should only support verification;
  • moreover falcoctl may support more than one standard (why should we stick just with one?).

As of today, Cosign and Notation seem equivalent to me, and I guess they both will converge to the OCI distribution-spec (sigstore confirmed their intention here. We may think of supporting both, IMO.

Finally, I believe it is worth bringing this discussion up to the whole Falcosecurity organization since there may be other sub-projects that want to sign their artifacts (likely, we want to use the same standards/tools across the entire org). Here is an example of a sub-project using cosign 👉 falcosecurity/falcosidekick#302

cc @falcosecurity/core-maintainers

@leogr
Copy link
Member

leogr commented Nov 23, 2022

The Helm way 👉 falcosecurity/charts#427

@maxgio92
Copy link
Member Author

Thanks @leogr. I see the point of the responsibility of verifying only the authenticity of the artifacts. And I agree as we discussed in the meantime.

I agree with the fact that all the implementations will converge to the OCI specification for artifacfs, for distribution. (as a detail, then we may want to discuss the encoding and signing algorithms to support, e.g. Notation supports JOSE and COSE).

I also agree with opening the discussion to the community in order to start talking about general signing at Falco organization-level, so that we make consistent choices on the architectures.

@maxgio92
Copy link
Member Author

maxgio92 commented Apr 6, 2023

As of the discussion of the today's supply chain security working group [1], I think we are on the same page on the responsibilities of the tools for the Falco OCI artifact's signature and signature verification:

  • signing: plugins and rules. The CI as code will implement generation and distribution of the signature of the artifact, as OCI artifact.
  • signature verification: falcoctl. The tool will implement a command to verify the signature of the Falco artifact, which is distributed as OCI artifact.

[1] References:

@LucaGuerra
Copy link
Contributor

I believe we can use this issue for the verify feature of Falcoctl while keeping two separate ones for rules and plugins. WDYT?

@maxgio92
Copy link
Member Author

I agree @LucaGuerra

@LucaGuerra LucaGuerra changed the title falcoctl sign/verify commands falcoctl cosign signature verififcation Jun 16, 2023
@LucaGuerra LucaGuerra changed the title falcoctl cosign signature verififcation falcoctl cosign signature verification Jun 16, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Falco Roadmap Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants