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

[Feature] Verify Image Policies in air gapped environment with TUF cache #8691

Open
2 tasks done
j1nka opened this issue Oct 19, 2023 · 6 comments
Open
2 tasks done
Labels
enhancement New feature or request imageVerify Image verification support

Comments

@j1nka
Copy link

j1nka commented Oct 19, 2023

Problem Statement

Hi!

If I'm right Kyverno will always try to get up-to-date keys from TUF and so it needs Internet connection. It calls tuf.Initialize(), which always will try to update TUF because of true in initializeTUF().

This may not be the best option in aig-gapped environment, where clusters doesn't have direct access to the Internet.

Solution Description

TUF itself has another function - newFromEnv(), which will try to use local cache if present and it's not forcing TUF update (false in initializeTUF().

It's possible to add this cache data to Kyverno pods. For example:

  1. We have workstation with internet access. We will download all necessary information, like remote.json, tuf.db, targets
  2. We will add additional init-container for Kyverno pods which will poppulate data above to emptyDir through ConfigMaps (for example)
  3. It works, and we don't need any direct Internet access from the cluster

Yes, there is another issue - we need to keep this data up-to-date, but it's still possible and not looks like tough task.

And there should be not so many code changes in Kyverno. Maybe we can add flag like useTufOffline (bool) and make something like this (in cmd\intenal\tuf.go):

if isTufOffline {
		if _, err = tuf.NewFromEnv(ctx); err != nil {
			checkError(logger, err, fmt.Sprintf("Failed to initialize TUF client from %s : %v", tufRoot, err))
		}
	} else {
		if err := tuf.Initialize(ctx, tufMirror, tufRootBytes); err != nil {
		 	checkError(logger, err, fmt.Sprintf("Failed to initialize TUF client from %s : %v", tufRoot, err))
		}
	}

What do you think about it? Or this idea is not good at all? Thanks!

Alternatives

No response

Additional Context

No response

Slack discussion

No response

Research

  • I have read and followed the documentation AND the troubleshooting guide.
  • I have searched other issues in this repository and mine is not recorded.
@j1nka j1nka added enhancement New feature or request triage Default label assigned to all new issues indicating label curation is needed to fully organize. labels Oct 19, 2023
@welcome
Copy link

welcome bot commented Oct 19, 2023

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

@vishal-chdhry
Copy link
Member

Hi @j1nka

it needs Internet connection. It calls tuf.Initialize(), which always will try to update TUF because of true in initializeTUF().

We are only initialising TUF when the flag, enableTUF is set to true otherwise we will just return.

func setupSigstoreTUF(ctx context.Context, logger logr.Logger) {
if !enableTUF {
return
}

@vishal-chdhry vishal-chdhry added imageVerify Image verification support and removed triage Default label assigned to all new issues indicating label curation is needed to fully organize. labels Oct 20, 2023
@j1nka
Copy link
Author

j1nka commented Oct 20, 2023

Hi @j1nka

it needs Internet connection. It calls tuf.Initialize(), which always will try to update TUF because of true in initializeTUF().

We are only initialising TUF when the flag, enableTUF is set to true otherwise we will just return.

func setupSigstoreTUF(ctx context.Context, logger logr.Logger) {
if !enableTUF {
return
}

@vishal-chdhry Hi! Thanks for your reply!

Yes, it does. But it looks like that there are two options:

Option 1 - Without TUF initialization:

  • When Kyverno trying to verify signature it also trying to download keys from the internet. Looks like it's not possible to run image verification in air gapped environments in this scenario

Option 2 - With TUF initialization:

  • Kyverno will use keys, which are already present. In that case it's possible to run image verification in air gapped environments (current FR)

Maybe i'm wrong, but i have some tests which approved the above statetments. Trying to find more information in code :)

@vishal-chdhry
Copy link
Member

vishal-chdhry commented Oct 20, 2023

When Kyverno trying to verify signature it also trying to download keys from the internet. Looks like it's not possible to run image verification in air gapped environments in this scenario

@j1nka You can use the rekor.pubKey and ctlog.pubkey to verify images without downloading keys from the internet

@j1nka
Copy link
Author

j1nka commented Oct 20, 2023

When Kyverno trying to verify signature it also trying to download keys from the internet. Looks like it's not possible to run image verification in air gapped environments in this scenario

@j1nka You can use the rekor.pubKey and ctlog.pubkey to verify images without downloading keys from the internet

@vishal-chdhry thanks! you mean something like this:

        attestations:
          - predicateType: https://example.com/CodeReview/v1
            attestors:
            - entries:
              - keys:
                  ctlog:
                    pubkey: |-
                        -----BEGIN PUBLIC KEY-----
                        XXX
                        -----END PUBLIC KEY-----
                  publicKeys: |-
                    -----BEGIN PUBLIC KEY-----
                    XXX
                    -----END PUBLIC KEY-----
                  rekor:
                    pubkey: |-
                        -----BEGIN PUBLIC KEY-----
                        XXX
                        -----END PUBLIC KEY-----
  

?

@vishal-chdhry
Copy link
Member

@j1nka Yes

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

No branches or pull requests

2 participants